diff options
204 files changed, 1082 insertions, 963 deletions
diff --git a/Documentation/DMA-mapping.txt b/Documentation/DMA-mapping.txt index 988561f90d0a..f7dd05294f4e 100644 --- a/Documentation/DMA-mapping.txt +++ b/Documentation/DMA-mapping.txt @@ -180,6 +180,19 @@ There are two types of DMA mappings: to memory is immediately visible to the device, and vice versa. Consistent mappings guarantee this. + IMPORTANT: Consistent DMA memory does not preclude the usage of + proper memory barriers. The cpu may reorder stores to + consistent memory just as it may normal memory. Example: + if it is important for the device to see the first word + of a descriptor updated before the second, you must do + something like: + + desc->word0 = address; + wmb(); + desc->word1 = DESC_VALID; + + in order to get correct behavior on all platforms. + - Streaming DMA mappings which are usually mapped for one DMA transfer, unmapped right after it (unless you use pci_dma_sync below) and for which hardware can optimize for sequential accesses. @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 9 -EXTRAVERSION =-pre4 +EXTRAVERSION = KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) diff --git a/arch/cris/drivers/usb-host.c b/arch/cris/drivers/usb-host.c index f2655d6f8800..87bad1b280f2 100644 --- a/arch/cris/drivers/usb-host.c +++ b/arch/cris/drivers/usb-host.c @@ -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 (leni, min (sizeof (root_hub_dev_des), wLength)); + len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_dev_des), wLength)); memcpy (data, root_hub_dev_des, len); OK (len); case (0x02): /* configuration descriptor */ - len = min (leni, min (sizeof (root_hub_config_des), wLength)); + len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_config_des), wLength)); memcpy (data, root_hub_config_des, len); OK (len); case (0x03): /* string descriptors */ @@ -2270,7 +2270,7 @@ static int etrax_rh_submit_urb(urb_t *urb) 0xff, "ETRAX 100LX", data, wLength); if (len > 0) { - OK (min (leni, len)); + OK(min(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 (leni, min (sizeof (root_hub_hub_des), wLength)); + len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_hub_des), wLength)); memcpy (data, root_hub_hub_des, len); OK (len); diff --git a/arch/cris/drivers/usb-host.h b/arch/cris/drivers/usb-host.h index 933b595403af..434d50b26021 100644 --- a/arch/cris/drivers/usb-host.h +++ b/arch/cris/drivers/usb-host.h @@ -146,8 +146,6 @@ struct in_chunk #define RH_REQ_ERR -1 #define RH_NACK 0x00 -#define min(a,b) (((a)<(b))?(a):(b)) - /* Field definitions for */ #define USB_IN_command__eol__BITNR 0 /* command macros */ diff --git a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c index 526a00e7461d..3ebf74d18d3f 100644 --- a/arch/i386/kernel/i386_ksyms.c +++ b/arch/i386/kernel/i386_ksyms.c @@ -161,3 +161,7 @@ EXPORT_SYMBOL_NOVERS(memset); #ifdef CONFIG_X86_PAE EXPORT_SYMBOL(empty_zero_page); #endif + +#ifdef CONFIG_HAVE_DEC_LOCK +EXPORT_SYMBOL(atomic_dec_and_lock); +#endif diff --git a/arch/sparc/kernel/head.S b/arch/sparc/kernel/head.S index b609bb102d64..d8e65b0ff4c7 100644 --- a/arch/sparc/kernel/head.S +++ b/arch/sparc/kernel/head.S @@ -1,4 +1,4 @@ -/* $Id: head.S,v 1.104 2001/04/27 07:02:41 davem Exp $ +/* $Id: head.S,v 1.105 2001/08/12 09:08:56 davem Exp $ * head.S: The initial boot code for the Sparc port of Linux. * * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) @@ -160,7 +160,7 @@ t_bad79:BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7 t_bad7e:BAD_TRAP(0x7e) BAD_TRAP(0x7f) t_sunos:SUNOS_SYSCALL_TRAP /* SunOS System Call */ t_sbkpt:BREAKPOINT_TRAP /* Software Breakpoint/KGDB */ -t_divz: BAD_TRAP(0x82) /* Divide by zero trap */ +t_divz: TRAP_ENTRY(0x82, do_hw_divzero) /* Divide by zero trap */ t_flwin:TRAP_ENTRY(0x83, do_flush_windows) /* Flush Windows Trap */ t_clwin:BAD_TRAP(0x84) /* Clean Windows Trap */ t_rchk: BAD_TRAP(0x85) /* Range Check */ @@ -245,7 +245,7 @@ C_LABEL(trapbase_cpu1): BAD_TRAP(0x7e) BAD_TRAP(0x7f) SUNOS_SYSCALL_TRAP BREAKPOINT_TRAP - BAD_TRAP(0x82) + TRAP_ENTRY(0x82, do_hw_divzero) TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85) BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) @@ -313,7 +313,7 @@ C_LABEL(trapbase_cpu2): BAD_TRAP(0x7e) BAD_TRAP(0x7f) SUNOS_SYSCALL_TRAP BREAKPOINT_TRAP - BAD_TRAP(0x82) + TRAP_ENTRY(0x82, do_hw_divzero) TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85) BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) @@ -381,7 +381,7 @@ C_LABEL(trapbase_cpu3): BAD_TRAP(0x7e) BAD_TRAP(0x7f) SUNOS_SYSCALL_TRAP BREAKPOINT_TRAP - BAD_TRAP(0x82) + TRAP_ENTRY(0x82, do_hw_divzero) TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85) BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) diff --git a/arch/sparc/kernel/sys_sunos.c b/arch/sparc/kernel/sys_sunos.c index 88933354d0fb..3180994194b8 100644 --- a/arch/sparc/kernel/sys_sunos.c +++ b/arch/sparc/kernel/sys_sunos.c @@ -1,4 +1,4 @@ -/* $Id: sys_sunos.c,v 1.134 2001/04/27 07:02:42 davem Exp $ +/* $Id: sys_sunos.c,v 1.135 2001/08/13 14:40:10 davem Exp $ * sys_sunos.c: SunOS specific syscall compatibility support. * * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig index 4051913366aa..085efdd15554 100644 --- a/arch/sparc64/defconfig +++ b/arch/sparc64/defconfig @@ -661,8 +661,10 @@ CONFIG_NLS_DEFAULT="iso8859-1" # Sound # CONFIG_SOUND=m +CONFIG_SOUND_BT878=m # CONFIG_SOUND_CMPCI is not set # CONFIG_SOUND_EMU10K1 is not set +# CONFIG_MIDI_EMU10K1 is not set # CONFIG_SOUND_FUSION is not set # CONFIG_SOUND_CS4281 is not set # CONFIG_SOUND_ES1370 is not set @@ -671,6 +673,7 @@ CONFIG_SOUND_ES1371=m # CONFIG_SOUND_MAESTRO is not set # CONFIG_SOUND_MAESTRO3 is not set # CONFIG_SOUND_ICH is not set +# CONFIG_SOUND_RME96XX is not set # CONFIG_SOUND_SONICVIBES is not set CONFIG_SOUND_TRIDENT=m # CONFIG_SOUND_MSNDCLAS is not set diff --git a/arch/sparc64/kernel/dtlb_backend.S b/arch/sparc64/kernel/dtlb_backend.S index e801cd4b6cbd..2a428c5f7f2d 100644 --- a/arch/sparc64/kernel/dtlb_backend.S +++ b/arch/sparc64/kernel/dtlb_backend.S @@ -1,4 +1,4 @@ -/* $Id: dtlb_backend.S,v 1.11 2001/08/08 08:01:28 davem Exp $ +/* $Id: dtlb_backend.S,v 1.12 2001/08/13 20:41:54 kanoj Exp $ * dtlb_backend.S: Back end to DTLB miss replacement strategy. * This is included directly into the trap table. * @@ -23,7 +23,7 @@ ldxa [%g1 + %g1] ASI_DMMU, %g4 ! Get TAG_ACCESS add %g3, %g3, %g5 ! Compute VPTE base cmp %g4, %g5 ! VPTE miss? - blu,pn %xcc, .-0x4004 ! Fall to tl0 miss + blu,pn %xcc, from_tl1_trap ! Fall to tl0 miss andcc %g4, TAG_CONTEXT_BITS, %g5 ! From Nucleus? (for tl0 miss) sllx %g6, VPTE_SHIFT, %g4 ! Position TAG_ACCESS or %g4, %g5, %g4 ! Prepare TAG_ACCESS @@ -57,10 +57,9 @@ sparc64_vpte_continue: stxa %g5, [%g0] ASI_DTLB_DATA_IN ! Load VPTE into TLB stxa %g4, [%g1 + %g1] ASI_DMMU ! Restore previous TAG_ACCESS retry ! Load PTE once again -vpte_noent: - mov TLB_SFSR, %g1 ! Restore %g1 value - stxa %g4, [%g1 + %g1] ASI_DMMU ! Restore previous TAG_ACCESS - done ! Slick trick + nop + nop + nop #undef TAG_CONTEXT_BITS #undef VPTE_SHIFT diff --git a/arch/sparc64/kernel/dtlb_base.S b/arch/sparc64/kernel/dtlb_base.S index f3a32d71406f..0d155e9b8896 100644 --- a/arch/sparc64/kernel/dtlb_base.S +++ b/arch/sparc64/kernel/dtlb_base.S @@ -1,4 +1,4 @@ -/* $Id: dtlb_base.S,v 1.9 2001/03/22 00:12:32 davem Exp $ +/* $Id: dtlb_base.S,v 1.10 2001/08/13 20:41:54 kanoj Exp $ * dtlb_base.S: Front end to DTLB miss replacement strategy. * This is included directly into the trap table. * @@ -51,6 +51,7 @@ /* DTLB ** ICACHE line 1: Quick user TLB misses */ ldxa [%g1 + %g1] ASI_DMMU, %g4 ! Get TAG_ACCESS andcc %g4, TAG_CONTEXT_BITS, %g0 ! From Nucleus? +from_tl1_trap: be,pn %xcc, 3f ! Yep, special processing srax %g4, VPTE_SHIFT, %g6 ! Create VPTE offset ldxa [%g3 + %g6] ASI_S, %g5 ! Load VPTE diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S index d76c85942a0d..76918a29a4bc 100644 --- a/arch/sparc64/kernel/entry.S +++ b/arch/sparc64/kernel/entry.S @@ -1,4 +1,4 @@ -/* $Id: entry.S,v 1.128 2001/03/28 10:56:34 davem Exp $ +/* $Id: entry.S,v 1.129 2001/08/13 20:41:54 kanoj Exp $ * arch/sparc64/kernel/entry.S: Sparc64 trap low-level entry points. * * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu) @@ -40,6 +40,11 @@ sparc64_vpte_patchme2: ba,pt %xcc, sparc64_kpte_continue ! Part of dtlb_backend add %g1, %g1, %g1 ! Finish PMD offset adjustment +vpte_noent: + mov TLB_SFSR, %g1 ! Restore %g1 value + stxa %g4, [%g1 + %g1] ASI_DMMU ! Restore previous TAG_ACCESS + done ! Slick trick + /* This is trivial with the new code... */ .globl do_fpdis do_fpdis: diff --git a/arch/sparc64/kernel/pci_common.c b/arch/sparc64/kernel/pci_common.c index 02dfa9b7904b..6b2f28077c4e 100644 --- a/arch/sparc64/kernel/pci_common.c +++ b/arch/sparc64/kernel/pci_common.c @@ -1,4 +1,4 @@ -/* $Id: pci_common.c,v 1.26 2001/06/28 01:32:18 davem Exp $ +/* $Id: pci_common.c,v 1.27 2001/08/12 13:18:22 davem Exp $ * pci_common.c: PCI controller common support. * * Copyright (C) 1999 David S. Miller (davem@redhat.com) @@ -723,12 +723,12 @@ static void __init pdev_fixup_irq(struct pci_dev *pdev) * ranges. -DaveM */ if (pdev->bus->number == pbm->pci_first_busno) { - slot = (pdev->devfn >> 3) - 1; + slot = (pdev->devfn >> 3) - pbm->pci_first_slot; } else { /* Underneath a bridge, use slot number of parent * bridge. */ - slot = (pdev->bus->self->devfn >> 3) - 1; + slot = (pdev->bus->self->devfn >> 3) - pbm->pci_first_slot; } slot = slot << 2; diff --git a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c index 9503de64c6b9..7333eeebf554 100644 --- a/arch/sparc64/kernel/pci_psycho.c +++ b/arch/sparc64/kernel/pci_psycho.c @@ -1,4 +1,4 @@ -/* $Id: pci_psycho.c,v 1.26 2001/06/13 06:34:30 davem Exp $ +/* $Id: pci_psycho.c,v 1.27 2001/08/12 13:18:23 davem Exp $ * pci_psycho.c: PSYCHO/U2P specific PCI controller support. * * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@caipfs.rutgers.edu) @@ -1477,14 +1477,23 @@ static void psycho_pbm_init(struct pci_controller_info *p, { unsigned int busrange[2]; struct pci_pbm_info *pbm; - int err; + char namebuf[64]; + int err, len; if (is_pbm_a) { pbm = &p->pbm_A; + pbm->pci_first_slot = 1; pbm->io_space.start = p->controller_regs + PSYCHO_IOSPACE_A; pbm->mem_space.start = p->controller_regs + PSYCHO_MEMSPACE_A; } else { pbm = &p->pbm_B; + pbm->pci_first_slot = 1; + len = prom_getproperty(prom_root_node, "name", + namebuf, sizeof(namebuf)); + if (len > 0) { + if (!strcmp(namebuf, "SUNW,Ultra-1-Engine")) + pbm->pci_first_slot = 2; + } pbm->io_space.start = p->controller_regs + PSYCHO_IOSPACE_B; pbm->mem_space.start = p->controller_regs + PSYCHO_MEMSPACE_B; } diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c index 1146d85ca459..f106c0998024 100644 --- a/arch/sparc64/kernel/pci_sabre.c +++ b/arch/sparc64/kernel/pci_sabre.c @@ -1,4 +1,4 @@ -/* $Id: pci_sabre.c,v 1.37 2001/06/13 06:34:30 davem Exp $ +/* $Id: pci_sabre.c,v 1.38 2001/08/12 13:18:23 davem Exp $ * pci_sabre.c: Sabre specific PCI controller support. * * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@caipfs.rutgers.edu) @@ -1395,6 +1395,7 @@ static void __init sabre_pbm_init(struct pci_controller_info *p, int sabre_node, pbm = &p->pbm_A; pbm->parent = p; pbm->prom_node = node; + pbm->pci_first_slot = 1; pbm->pci_first_busno = busrange[0]; pbm->pci_last_busno = busrange[1]; for (err = pbm->pci_first_busno; diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c index af7fe5b0245f..05965f14aa24 100644 --- a/arch/sparc64/kernel/pci_schizo.c +++ b/arch/sparc64/kernel/pci_schizo.c @@ -1,4 +1,4 @@ -/* $Id: pci_schizo.c,v 1.19 2001/06/20 21:31:00 davem Exp $ +/* $Id: pci_schizo.c,v 1.20 2001/08/12 13:18:23 davem Exp $ * pci_schizo.c: SCHIZO specific PCI controller support. * * Copyright (C) 2001 David S. Miller (davem@redhat.com) @@ -1684,6 +1684,7 @@ static void schizo_pbm_init(struct pci_controller_info *p, pbm->parent = p; pbm->prom_node = prom_node; + pbm->pci_first_slot = 1; prom_getstring(prom_node, "name", pbm->prom_name, sizeof(pbm->prom_name)); diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c index fb73ba1e3865..4409886f00ba 100644 --- a/arch/sparc64/kernel/sparc64_ksyms.c +++ b/arch/sparc64/kernel/sparc64_ksyms.c @@ -163,6 +163,7 @@ EXPORT_SYMBOL(__up); /* Atomic counter implementation. */ EXPORT_SYMBOL(__atomic_add); EXPORT_SYMBOL(__atomic_sub); +EXPORT_SYMBOL(atomic_dec_and_lock); /* Atomic bit operations. */ EXPORT_SYMBOL(___test_and_set_bit); diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c index d4a8c18564db..1deac8f74ce8 100644 --- a/arch/sparc64/kernel/sys_sparc32.c +++ b/arch/sparc64/kernel/sys_sparc32.c @@ -1,4 +1,4 @@ -/* $Id: sys_sparc32.c,v 1.177 2001/06/10 06:48:46 davem Exp $ +/* $Id: sys_sparc32.c,v 1.178 2001/08/13 14:40:07 davem Exp $ * sys_sparc32.c: Conversion between 32bit and 64bit native syscalls. * * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) diff --git a/arch/sparc64/kernel/sys_sunos32.c b/arch/sparc64/kernel/sys_sunos32.c index bba037f2c587..39e2781f57d3 100644 --- a/arch/sparc64/kernel/sys_sunos32.c +++ b/arch/sparc64/kernel/sys_sunos32.c @@ -1,4 +1,4 @@ -/* $Id: sys_sunos32.c,v 1.60 2001/04/27 07:02:42 davem Exp $ +/* $Id: sys_sunos32.c,v 1.61 2001/08/13 14:40:07 davem Exp $ * sys_sunos32.c: SunOS binary compatability layer on sparc64. * * Copyright (C) 1995, 1996, 1997 David S. Miller (davem@caip.rutgers.edu) diff --git a/arch/sparc64/kernel/ttable.S b/arch/sparc64/kernel/ttable.S index bda69c8f2f7b..008c780fd1cd 100644 --- a/arch/sparc64/kernel/ttable.S +++ b/arch/sparc64/kernel/ttable.S @@ -1,4 +1,4 @@ -/* $Id: ttable.S,v 1.33 2001/03/28 10:56:34 davem Exp $ +/* $Id: ttable.S,v 1.34 2001/08/12 09:08:56 davem Exp $ * ttable.S: Sparc V9 Trap Table(s) with SpitFire/Cheetah extensions. * * Copyright (C) 1996, 2001 David S. Miller (davem@caip.rutgers.edu) @@ -106,7 +106,7 @@ tl0_f6o: FILL_6_OTHER tl0_f7o: FILL_7_OTHER tl0_sunos: SUNOS_SYSCALL_TRAP tl0_bkpt: BREAKPOINT_TRAP -tl0_resv102: BTRAP(0x102) +tl0_divz: TRAP(do_div0) tl0_flushw: FLUSH_WINDOW_TRAP tl0_resv104: BTRAP(0x104) BTRAP(0x105) BTRAP(0x106) BTRAP(0x107) .globl tl0_solaris diff --git a/arch/sparc64/solaris/timod.c b/arch/sparc64/solaris/timod.c index 6ec858af0696..283e0e37c241 100644 --- a/arch/sparc64/solaris/timod.c +++ b/arch/sparc64/solaris/timod.c @@ -1,4 +1,4 @@ -/* $Id: timod.c,v 1.11 2001/04/14 21:12:01 davem Exp $ +/* $Id: timod.c,v 1.15 2001/08/13 18:56:10 davem Exp $ * timod.c: timod emulation. * * Copyright (C) 1998 Patrik Rak (prak3264@ss1000.ms.mff.cuni.cz) @@ -699,10 +699,7 @@ 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; -#ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) -#endif - int l = min(ctl_maxlen, it->length); + int l = min(int, ctl_maxlen, it->length); SCHECK_MAGIC((char*)((u64)(((char *)&it->type)+sock->offset+it->length+7)&~7),MKCTL_MAGIC); SOLD("purting ctl data"); if(copy_to_user(ctl_buf, @@ -815,7 +812,7 @@ int timod_getmsg(unsigned int fd, char *ctl_buf, int ctl_maxlen, s32 *ctl_len, filp->f_flags |= O_NONBLOCK; SOLD("calling recvfrom"); sys_recvfrom = (int (*)(int, void *, size_t, unsigned, struct sockaddr *, int *))SYS(recvfrom); - error = sys_recvfrom(fd, data_buf, min(0,data_maxlen), 0, (struct sockaddr*)tmpbuf, ctl_len); + error = sys_recvfrom(fd, data_buf, data_maxlen, 0, (struct sockaddr*)tmpbuf, ctl_len); filp->f_flags = oldflags; if (error < 0) return error; diff --git a/drivers/acorn/scsi/acornscsi.c b/drivers/acorn/scsi/acornscsi.c index a5184513f7fd..66525f304374 100644 --- a/drivers/acorn/scsi/acornscsi.c +++ b/drivers/acorn/scsi/acornscsi.c @@ -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(host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2); + length = min(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2); if (length) { host->dma.start_addr = address = host->dma.free_addr; host->dma.free_addr = (host->dma.free_addr + length) & @@ -1187,7 +1187,7 @@ void acornscsi_dma_intr(AS_Host *host) /* * Allocate some buffer space, limited to half the on-board RAM size */ - length = min(host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2); + length = min(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2); if (length) { host->dma.start_addr = address = host->dma.free_addr; host->dma.free_addr = (host->dma.free_addr + length) & @@ -1656,8 +1656,8 @@ 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(message[3], sdtr_period / 4); - length = min(message[4], sdtr_size); + period = max(unsigned int, message[3], sdtr_period / 4); + length = min(unsigned int, message[4], sdtr_size); msgqueue_addmsg(&host->scsi.msgs, 5, EXTENDED_MESSAGE, 3, EXTENDED_SDTR, period, length); host->device[host->SCpnt->target].sync_xfer = diff --git a/drivers/acorn/scsi/acornscsi.h b/drivers/acorn/scsi/acornscsi.h index 74a92d525c0a..191d16af8c45 100644 --- a/drivers/acorn/scsi/acornscsi.h +++ b/drivers/acorn/scsi/acornscsi.h @@ -183,9 +183,6 @@ #define MASK_ON (MASKREG_M3|MASKREG_M2|MASKREG_M1|MASKREG_M0) #define MASK_OFF (MASKREG_M3|MASKREG_M2|MASKREG_M1) -#define min(x,y) ((x) < (y) ? (x) : (y)) -#define max(x,y) ((x) < (y) ? (y) : (x)) - /* * SCSI driver phases */ diff --git a/drivers/block/acsi.c b/drivers/block/acsi.c index 7992a8739516..e1d1a3566674 100644 --- a/drivers/block/acsi.c +++ b/drivers/block/acsi.c @@ -292,9 +292,6 @@ static char pa_med_rem_cmd[6] = { 0x1e, 0, 0, 0, 0, 0 }; cmd[4] = (len); \ } while(0) -#define min(a,b) (((a)<(b))?(a):(b)) - - /* ACSI errors (from REQUEST SENSE); There are two tables, one for the * old Atari disks and one for SCSI on ACSI disks. */ diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index b3b6c9d6c249..6e68c18d7bca 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -2246,8 +2246,13 @@ int cdrom_get_track_info(kdev_t dev, __u16 track, __u8 type, if ((ret = cdo->generic_packet(cdi, &cgc))) return ret; - cgc.cmd[8] = cgc.buflen = be16_to_cpu(ti->track_information_length) + + cgc.buflen = be16_to_cpu(ti->track_information_length) + sizeof(ti->track_information_length); + + if (cgc.buflen > sizeof(track_information)) + cgc.buflen = sizeof(track_information); + + cgc.cmd[8] = cgc.buflen; return cdo->generic_packet(cdi, &cgc); } diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h index ac94c07dcf31..7057a62d73fe 100644 --- a/drivers/char/agp/agp.h +++ b/drivers/char/agp/agp.h @@ -142,10 +142,6 @@ struct agp_bridge_data { #define A_IDXFIX() (A_SIZE_FIX(agp_bridge.aperture_sizes) + i) #define MAXKEY (4096 * 32) -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif - #define AGPGART_MODULE_NAME "agpgart" #define PFX AGPGART_MODULE_NAME ": " diff --git a/drivers/char/agp/agpgart_be.c b/drivers/char/agp/agpgart_be.c index e1bd9f6b74b2..3658ef10cbd5 100644 --- a/drivers/char/agp/agpgart_be.c +++ b/drivers/char/agp/agpgart_be.c @@ -428,8 +428,8 @@ static void agp_generic_agp_enable(u32 mode) /* adjust RQ depth */ command = ((command & ~0xff000000) | - min((mode & 0xff000000), - min((command & 0xff000000), + min(u32, (mode & 0xff000000), + min(u32, (command & 0xff000000), (scratch & 0xff000000)))); /* disable SBA if it's not supported */ @@ -2657,8 +2657,8 @@ static void serverworks_agp_enable(u32 mode) /* adjust RQ depth */ command = ((command & ~0xff000000) | - min((mode & 0xff000000), - min((command & 0xff000000), + min(u32, (mode & 0xff000000), + min(u32, (command & 0xff000000), (scratch & 0xff000000)))); /* disable SBA if it's not supported */ diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index ba42e8e2853c..a9c385602cde 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -628,8 +628,6 @@ static char rcsid[] = #define PAUSE ; #endif -#define cy_min(a,b) (((a)<(b))?(a):(b)) - /* * Include section */ @@ -1631,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 = - cy_min((rx_bufsize - new_rx_get), - cy_min((TTY_FLIPBUF_SIZE - tty->flip.count), char_count)) + min(unsigned int, (rx_bufsize - new_rx_get), + min(unsigned int, (TTY_FLIPBUF_SIZE - tty->flip.count), char_count)) )) { memcpy_fromio(tty->flip.char_buf_ptr, (char *)(cinfo->base_addr @@ -1726,9 +1724,9 @@ cyz_handle_tx(struct cyclades_port *info, volatile struct CH_CTRL *ch_ctrl, } #ifdef BLOCKMOVE while(0 < (small_count = - cy_min((tx_bufsize - tx_put), - cy_min ((SERIAL_XMIT_SIZE - info->xmit_tail), - cy_min(info->xmit_cnt, char_count))))){ + min(unsigned int, (tx_bufsize - tx_put), + min(unsigned int, (SERIAL_XMIT_SIZE - info->xmit_tail), + min(unsigned int, info->xmit_cnt, char_count))))) { memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr + tx_put), &info->xmit_buf[info->xmit_tail], diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index 845b5d61e03c..28d92604b111 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c @@ -59,9 +59,6 @@ #define DSP56K_TRANSMIT (dsp56k_host_interface.isr & DSP56K_ISR_TXDE) #define DSP56K_RECEIVE (dsp56k_host_interface.isr & DSP56K_ISR_RXDF) -#define max(a,b) ((a) > (b) ? (a) : (b)) -#define min(a,b) ((a) < (b) ? (a) : (b)) - #define wait_some(n) \ { \ set_current_state(TASK_INTERRUPTIBLE); \ @@ -72,7 +69,7 @@ { \ long i, t, m; \ while (count > 0) { \ - m = min(count, maxio); \ + m = min(unsigned long, count, maxio); \ for (i = 0; i < m; i++) { \ for (t = 0; t < timeout && !ENABLE; t++) \ wait_some(HZ/50); \ diff --git a/drivers/char/dz.c b/drivers/char/dz.c index 94876285307c..9104b838d41d 100644 --- a/drivers/char/dz.c +++ b/drivers/char/dz.c @@ -1279,7 +1279,8 @@ static void show_serial_version (void) int __init dz_init(void) { - int i, flags; + int i; + unsigned long flags; struct dz_serial *info; /* Setup base handler, and timer table. */ diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c index 5c34fd07f5cf..ca5e0c752191 100644 --- a/drivers/char/n_r3964.c +++ b/drivers/char/n_r3964.c @@ -1421,7 +1421,7 @@ static unsigned int r3964_poll(struct tty_struct * tty, struct file * file, int pid=current->pid; struct r3964_client_info *pClient; struct r3964_message *pMsg=NULL; - unsigned int flags; + unsigned long flags; int result = POLLOUT; TRACE_L("POLL"); diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 3124ccf965bd..d4c94cc492f2 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -71,10 +71,6 @@ #define PP_VERSION "ppdev: user-space parallel port driver" #define CHRDEV "ppdev" -#ifndef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#endif - struct pp_struct { struct pardevice * pdev; wait_queue_head_t irq_wait; @@ -122,7 +118,7 @@ static ssize_t pp_read (struct file * file, char * buf, size_t count, return -EINVAL; } - kbuffer = kmalloc (min (count, PP_BUFFER_SIZE), GFP_KERNEL); + kbuffer = kmalloc(min(unsigned int, count, PP_BUFFER_SIZE), GFP_KERNEL); if (!kbuffer) { return -ENOMEM; } @@ -130,7 +126,7 @@ 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(count - bytes_read, PP_BUFFER_SIZE); + ssize_t need = min(unsigned long, count - bytes_read, PP_BUFFER_SIZE); if (mode == IEEE1284_MODE_EPP) { /* various specials for EPP mode */ @@ -202,7 +198,7 @@ static ssize_t pp_write (struct file * file, const char * buf, size_t count, return -EINVAL; } - kbuffer = kmalloc (min (count, PP_BUFFER_SIZE), GFP_KERNEL); + kbuffer = kmalloc(min(unsigned int, count, PP_BUFFER_SIZE), GFP_KERNEL); if (!kbuffer) { return -ENOMEM; } @@ -210,7 +206,7 @@ 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(count - bytes_written, PP_BUFFER_SIZE); + ssize_t n = min(unsigned long, count - bytes_written, PP_BUFFER_SIZE); if (copy_from_user (kbuffer, buf + bytes_written, n)) { bytes_written = -EFAULT; diff --git a/drivers/char/rio/rio.h b/drivers/char/rio/rio.h index a66e4efa280d..88aa1f34254e 100644 --- a/drivers/char/rio/rio.h +++ b/drivers/char/rio/rio.h @@ -210,16 +210,6 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3"; #define RIO_PORT(DEV,FIRST_MAJ) ( (major(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \ + minor(DEV) -/* -** Min and Max -*/ -#ifndef min -#define min(A,B) ((A)<(B)?(A):(B)) -#endif -#ifndef max -#define max(A,B) ((A)>(B)?(A):(B)) -#endif - #define splrio spltty #define RIO_IPL 5 diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c index c97f88640f40..ad8a70df19f8 100644 --- a/drivers/char/rio/riointr.c +++ b/drivers/char/rio/riointr.c @@ -819,7 +819,7 @@ struct Port * PortP; ** and available space. */ - transCount = min(PacketP->len & PKT_LEN_MASK, + transCount = min(unsigned int, PacketP->len & PKT_LEN_MASK, TTY_FLIPBUF_SIZE - TtyP->flip.count); rio_dprintk (RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount); diff --git a/drivers/i2o/i2o_block.c b/drivers/i2o/i2o_block.c index c2b755546d6f..039a176c49e6 100644 --- a/drivers/i2o/i2o_block.c +++ b/drivers/i2o/i2o_block.c @@ -713,7 +713,7 @@ static void i2o_block_reply(struct i2o_handler *h, struct i2o_controller *c, str static int i2ob_evt(void *dummy) { unsigned int evt; - unsigned int flags; + unsigned long flags; int unit; int i; //The only event that has data is the SCSI_SMART event. @@ -1698,7 +1698,7 @@ void i2ob_del_device(struct i2o_controller *c, struct i2o_device *d) { int unit = 0; int i = 0; - int flags; + unsigned long flags; spin_lock_irqsave(&io_request_lock, flags); diff --git a/drivers/i2o/i2o_config.c b/drivers/i2o/i2o_config.c index 02d0946dbe86..311b535279cf 100644 --- a/drivers/i2o/i2o_config.c +++ b/drivers/i2o/i2o_config.c @@ -790,7 +790,7 @@ static int ioctl_evt_get(unsigned long arg, struct file *fp) struct i2o_cfg_info *p = NULL; struct i2o_evt_get *uget = (struct i2o_evt_get*)arg; struct i2o_evt_get kget; - unsigned int flags; + unsigned long flags; for(p = open_files; p; p = p->next) if(p->q_id == id) @@ -819,7 +819,7 @@ static int cfg_open(struct inode *inode, struct file *file) { struct i2o_cfg_info *tmp = (struct i2o_cfg_info *)kmalloc(sizeof(struct i2o_cfg_info), GFP_KERNEL); - unsigned int flags; + unsigned long flags; if(!tmp) return -ENOMEM; @@ -845,7 +845,7 @@ static int cfg_release(struct inode *inode, struct file *file) { u32 id = (u32)file->private_data; struct i2o_cfg_info *p1, *p2; - unsigned int flags; + unsigned long flags; lock_kernel(); p1 = p2 = NULL; diff --git a/drivers/i2o/i2o_core.c b/drivers/i2o/i2o_core.c index 61ae192b8cb9..d4d0d0e75351 100644 --- a/drivers/i2o/i2o_core.c +++ b/drivers/i2o/i2o_core.c @@ -890,7 +890,7 @@ static int i2o_core_evt(void *reply_data) struct reply_info *reply = (struct reply_info *) reply_data; u32 *msg = reply->msg; struct i2o_controller *c = NULL; - int flags; + unsigned long flags; lock_kernel(); daemonize(); @@ -2535,7 +2535,7 @@ int i2o_post_wait_mem(struct i2o_controller *c, u32 *msg, int len, int timeout, DECLARE_WAIT_QUEUE_HEAD(wq_i2o_post); int complete = 0; int status; - int flags = 0; + unsigned long flags = 0; struct i2o_post_wait_data *wait_data = kmalloc(sizeof(struct i2o_post_wait_data), GFP_KERNEL); diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c index 1e07e0736a2a..9e98c56969d3 100644 --- a/drivers/ide/hpt366.c +++ b/drivers/ide/hpt366.c @@ -60,6 +60,11 @@ const char *bad_ata100_5[] = { "IBM-DTLA-305040", "IBM-DTLA-305030", "IBM-DTLA-305020", + "IC35L010AVER07-0", + "IC35L020AVER07-0", + "IC35L030AVER07-0", + "IC35L040AVER07-0", + "IC35L060AVER07-0", "WDC AC310200R", NULL }; @@ -74,6 +79,11 @@ const char *bad_ata66_4[] = { "IBM-DTLA-305040", "IBM-DTLA-305030", "IBM-DTLA-305020", + "IC35L010AVER07-0", + "IC35L020AVER07-0", + "IC35L030AVER07-0", + "IC35L040AVER07-0", + "IC35L060AVER07-0", "WDC AC310200R", NULL }; diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 87ae9b61d438..7320b177e7bd 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -1885,7 +1885,7 @@ static int cdrom_eject(ide_drive_t *drive, int ejectflag, return cdrom_queue_packet_command (drive, &pc); } -static int cdrom_read_capacity(ide_drive_t *drive, unsigned *capacity, +static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, struct request_sense *sense) { struct { @@ -2927,7 +2927,7 @@ void ide_cdrom_revalidate (ide_drive_t *drive) static unsigned long ide_cdrom_capacity (ide_drive_t *drive) { - unsigned capacity; + unsigned long capacity; if (cdrom_read_capacity(drive, &capacity, NULL)) return 0; diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index 702f3be3c85c..aa46a912ab31 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h @@ -150,7 +150,7 @@ struct atapi_toc_entry { struct atapi_toc { int last_session_lba; int xa_flag; - unsigned capacity; + unsigned long capacity; struct atapi_toc_header hdr; struct atapi_toc_entry ent[MAX_TRACKS+1]; /* One extra for the leadout. */ diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 0b3228949be3..fffc893b7774 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c @@ -358,7 +358,7 @@ static void nodemgr_node_probe(void *data) nodeid_t nodeid = LOCAL_BUS; quadlet_t buffer[5], quad; octlet_t base = CSR_REGISTER_BASE + CSR_CONFIG_ROM; - int flags; + unsigned long flags; /* We need to detect when the ConfigROM's generation has changed, * so we only update the node's info when it needs to be. */ @@ -508,7 +508,7 @@ int hpsb_guid_fill_packet(struct node_entry *ne, struct hpsb_packet *pkt) static void nodemgr_add_host(struct hpsb_host *host) { struct host_info *hi = kmalloc (sizeof (struct host_info), GFP_KERNEL); - int flags; + unsigned long flags; if (!hi) { HPSB_ERR ("Out of memory in Node Manager"); @@ -532,7 +532,7 @@ static void nodemgr_host_reset(struct hpsb_host *host) { struct list_head *lh; struct host_info *hi = NULL; - int flags; + unsigned long flags; spin_lock_irqsave (&host_info_lock, flags); list_for_each(lh, &host_info_list) { @@ -561,7 +561,7 @@ static void nodemgr_remove_host(struct hpsb_host *host) struct list_head *lh; struct host_info *hi = NULL; struct node_entry *ne; - int flags; + unsigned long flags; /* Make sure we have no active scans */ flush_scheduled_tasks(); diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 090104a81a73..8e0509de9ac6 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c @@ -200,7 +200,8 @@ static void dma_trm_reset(struct dma_trm_ctx *d); static u8 get_phy_reg(struct ti_ohci *ohci, u8 addr) { - int i, flags; + int i; + unsigned long flags; quadlet_t r; spin_lock_irqsave (&ohci->phy_reg_lock, flags); @@ -227,7 +228,8 @@ static u8 get_phy_reg(struct ti_ohci *ohci, u8 addr) static void set_phy_reg(struct ti_ohci *ohci, u8 addr, u8 data) { - int i, flags; + int i; + unsigned long flags; u32 r; spin_lock_irqsave (&ohci->phy_reg_lock, flags); @@ -1078,7 +1080,8 @@ static void ohci_irq_handler(int irq, void *dev_id, quadlet_t event, node_id; struct ti_ohci *ohci = (struct ti_ohci *)dev_id; struct hpsb_host *host = ohci->host; - int phyid = -1, isroot = 0, flags; + int phyid = -1, isroot = 0; + unsigned long flags; /* Read the interrupt event register. We don't clear the bus reset * here. We wait till we get a selfid complete interrupt and clear @@ -1343,7 +1346,8 @@ static void dma_rcv_tasklet (unsigned long data) struct ti_ohci *ohci = (struct ti_ohci*)(d->ohci); unsigned int split_left, idx, offset, rescount; unsigned char tcode; - int length, bytes_left, ack, flags; + int length, bytes_left, ack; + unsigned long flags; quadlet_t *buf_ptr; char *split_ptr; char msg[256]; diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 2fb0d374a6e9..a69131f98d82 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -965,7 +965,7 @@ void sbp2_cleanup(void) static void sbp2_add_host(struct hpsb_host *host) { struct sbp2scsi_host_info *hi; - unsigned int flags; + unsigned long flags; SBP2_DEBUG("sbp2: sbp2_add_host"); @@ -1048,7 +1048,7 @@ static void sbp2_remove_host(struct hpsb_host *host) { struct sbp2scsi_host_info *hi; int i; - unsigned int flags; + unsigned long flags; SBP2_DEBUG("sbp2: sbp2_remove_host"); diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index bea5d771057d..291d2579d600 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c @@ -1313,7 +1313,8 @@ int video1394_mmap(struct file *file, struct vm_area_struct *vma) { struct video_card *video = NULL; struct ti_ohci *ohci; - int res = -EINVAL, flags; + int res = -EINVAL; + unsigned long flags; struct list_head *lh; spin_lock_irqsave(&video1394_cards_lock, flags); @@ -1350,7 +1351,8 @@ int video1394_mmap(struct file *file, struct vm_area_struct *vma) static int video1394_open(struct inode *inode, struct file *file) { - int i = MINOR(inode->i_rdev), flags; + int i = MINOR(inode->i_rdev); + unsigned long flags; struct video_card *video = NULL; struct list_head *lh; @@ -1380,7 +1382,8 @@ static int video1394_release(struct inode *inode, struct file *file) struct video_card *video = NULL; struct ti_ohci *ohci; u64 mask; - int i, flags; + int i; + unsigned long flags; struct list_head *lh; spin_lock_irqsave(&video1394_cards_lock, flags); @@ -1446,7 +1449,8 @@ static int video1394_release(struct inode *inode, struct file *file) static void irq_handler(int card, quadlet_t isoRecvIntEvent, quadlet_t isoXmitIntEvent) { - int i, flags; + int i; + unsigned long flags; struct video_card *video = NULL; struct list_head *lh; @@ -1495,7 +1499,7 @@ static struct file_operations video1394_fops= static int video1394_init(struct ti_ohci *ohci) { struct video_card *video = kmalloc(sizeof(struct video_card), GFP_KERNEL); - int flags; + unsigned long flags; char name[16]; if (video == NULL) { @@ -1555,7 +1559,8 @@ static int video1394_init(struct ti_ohci *ohci) /* Must be called under spinlock */ static void remove_card(struct video_card *video) { - int i, flags; + int i; + unsigned long flags; ohci1394_unregister_video(video->ohci, &video_tmpl); @@ -1586,7 +1591,7 @@ static void remove_card(struct video_card *video) static void video1394_remove_host (struct hpsb_host *host) { struct ti_ohci *ohci; - int flags; + unsigned long flags; struct list_head *lh; /* We only work with the OHCI-1394 driver */ diff --git a/drivers/md/lvm-snap.c b/drivers/md/lvm-snap.c index 20e40c022e90..ed19d45fc895 100644 --- a/drivers/md/lvm-snap.c +++ b/drivers/md/lvm-snap.c @@ -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(blksize_org, blksize_snap); - min_blksize = min(blksize_org, blksize_snap); + max_blksize = max(int, blksize_org, blksize_snap); + min_blksize = min(int, blksize_org, blksize_snap); max_sectors = KIO_MAX_SECTORS * (min_blksize>>9); if (chunk_size % (max_blksize>>9)) @@ -395,7 +395,7 @@ int lvm_snapshot_COW(kdev_t org_phys_dev, while (chunk_size) { - nr_sectors = min(chunk_size, max_sectors); + nr_sectors = min(int, chunk_size, max_sectors); chunk_size -= nr_sectors; iobuf->length = nr_sectors << 9; @@ -503,7 +503,7 @@ int lvm_snapshot_alloc_hash_table(lv_t * lv) buckets = lv->lv_remap_end; max_buckets = calc_max_buckets(); - buckets = min(buckets, max_buckets); + buckets = min(unsigned long, buckets, max_buckets); while (buckets & (buckets-1)) buckets &= (buckets-1); diff --git a/drivers/mtd/devices/docecc.c b/drivers/mtd/devices/docecc.c index c10ff2b88bcc..f161a130a12f 100644 --- a/drivers/mtd/devices/docecc.c +++ b/drivers/mtd/devices/docecc.c @@ -80,8 +80,6 @@ modnn(int x) return x; } -#define min(a,b) ((a) < (b) ? (a) : (b)) - #define CLEAR(a,n) {\ int ci;\ for(ci=(n)-1;ci >=0;ci--)\ @@ -404,7 +402,7 @@ 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(deg_lambda,NN-KK-1) & ~1; i >= 0; i -=2) { + for (i = min(int, deg_lambda,NN-KK-1) & ~1; i >= 0; i -=2) { if(lambda[i+1] != A0) den ^= Alpha_to[modnn(lambda[i+1] + i * root[j])]; } diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c index bc8ef6891a33..3b5f6df4f130 100644 --- a/drivers/net/acenic.c +++ b/drivers/net/acenic.c @@ -157,10 +157,6 @@ MODULE_DEVICE_TABLE(pci, acenic_pci_tbl); #define __devinit __init #endif -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif - #ifndef SMP_CACHE_BYTES #define SMP_CACHE_BYTES L1_CACHE_BYTES #endif @@ -2999,8 +2995,8 @@ static void __init ace_copy(struct ace_regs *regs, void *src, return; while (size > 0) { - tsize = min(((~dest & (ACE_WINDOW_SIZE - 1)) + 1), - min(size, ACE_WINDOW_SIZE)); + tsize = min(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1), + min(u32, size, ACE_WINDOW_SIZE)); tdest = (unsigned long)®s->Window + (dest & (ACE_WINDOW_SIZE - 1)); writel(dest & ~(ACE_WINDOW_SIZE - 1), ®s->WinBase); @@ -3030,8 +3026,8 @@ static void __init ace_clear(struct ace_regs *regs, u32 dest, int size) return; while (size > 0) { - tsize = min(((~dest & (ACE_WINDOW_SIZE - 1)) + 1), - min(size, ACE_WINDOW_SIZE)); + tsize = min(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1), + min(u32, size, ACE_WINDOW_SIZE)); tdest = (unsigned long)®s->Window + (dest & (ACE_WINDOW_SIZE - 1)); writel(dest & ~(ACE_WINDOW_SIZE - 1), ®s->WinBase); diff --git a/drivers/net/de600.c b/drivers/net/de600.c index d161342c0896..d582b16db936 100644 --- a/drivers/net/de600.c +++ b/drivers/net/de600.c @@ -801,7 +801,6 @@ adapter_init(struct net_device *dev) * This differs from the standard function, that can return an * arbitrarily small window! */ -#define min(a,b) ((a)<(b)?(a):(b)) static unsigned long de600_rspace(struct sock *sk) { @@ -815,7 +814,7 @@ de600_rspace(struct sock *sk) */ if (atomic_read(&sk->rmem_alloc) >= sk->rcvbuf-2*DE600_MIN_WINDOW) return(0); - amt = min((sk->rcvbuf-atomic_read(&sk->rmem_alloc))/2/*-DE600_MIN_WINDOW*/, DE600_MAX_WINDOW); + amt = min(int, (sk->rcvbuf-atomic_read(&sk->rmem_alloc))/2/*-DE600_MIN_WINDOW*/, DE600_MAX_WINDOW); if (amt < 0) return(0); return(amt); } diff --git a/drivers/net/dgrs.c b/drivers/net/dgrs.c index 65616e697179..542f526a004d 100644 --- a/drivers/net/dgrs.c +++ b/drivers/net/dgrs.c @@ -693,7 +693,6 @@ static int dgrs_start_xmit(struct sk_buff *skb, struct net_device *devN) I596_RBD *rbdp; int count; int i, len, amt; -# define mymin(A,B) ( (A) < (B) ? (A) : (B) ) /* * Determine 0th priv and dev structure pointers @@ -734,7 +733,7 @@ static int dgrs_start_xmit(struct sk_buff *skb, struct net_device *devN) goto no_resources; } - amt = mymin(len, rbdp->size - count); + amt = min(unsigned int, len, rbdp->size - count); memcpy( (char *) S2H(rbdp->buf) + count, skb->data + i, amt); i += amt; count += amt; diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index 7c8aef881001..403577fda957 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c @@ -246,11 +246,6 @@ struct baycom_state { /* --------------------------------------------------------------------- */ -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#define max(a, b) (((a) > (b)) ? (a) : (b)) - -/* --------------------------------------------------------------------- */ - #define KISS_VERBOSE /* --------------------------------------------------------------------- */ @@ -615,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(cnt, bc->hdlctx.flags); + i = min(int, cnt, bc->hdlctx.flags); cnt -= i; bc->hdlctx.flags -= i; if (bc->hdlctx.flags <= 0) @@ -638,7 +633,7 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat) break; } } - i = min(cnt, bc->hdlctx.bufcnt); + i = min(int, cnt, bc->hdlctx.bufcnt); bc->hdlctx.bufcnt -= i; cnt -= i; if (i != pp->ops->epp_write_data(pp, bc->hdlctx.bufptr, i, 0)) @@ -652,7 +647,7 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat) bc->hdlctx.state = tx_data; break; } - i = min(cnt, bc->hdlctx.flags); + i = min(int, cnt, bc->hdlctx.flags); if (i) { cnt -= i; bc->hdlctx.flags -= i; @@ -669,7 +664,7 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat) default: /* fall through */ if (bc->hdlctx.calibrate <= 0) return 0; - i = min(cnt, bc->hdlctx.calibrate); + i = min(int, cnt, bc->hdlctx.calibrate); cnt -= i; bc->hdlctx.calibrate -= i; memset(tmp, 0, sizeof(tmp)); diff --git a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c index 61cfd41480b2..508b6dc37463 100644 --- a/drivers/net/hamradio/baycom_par.c +++ b/drivers/net/hamradio/baycom_par.c @@ -157,11 +157,6 @@ struct baycom_state { /* --------------------------------------------------------------------- */ -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#define max(a, b) (((a) > (b)) ? (a) : (b)) - -/* --------------------------------------------------------------------- */ - static void __inline__ baycom_int_freq(struct baycom_state *bc) { #ifdef BAYCOM_DEBUG diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c index 2b19dc9058a6..c1c3fc6ca023 100644 --- a/drivers/net/hamradio/baycom_ser_fdx.c +++ b/drivers/net/hamradio/baycom_ser_fdx.c @@ -152,11 +152,6 @@ struct baycom_state { /* --------------------------------------------------------------------- */ -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#define max(a, b) (((a) > (b)) ? (a) : (b)) - -/* --------------------------------------------------------------------- */ - static void inline baycom_int_freq(struct baycom_state *bc) { #ifdef BAYCOM_DEBUG diff --git a/drivers/net/hamradio/baycom_ser_hdx.c b/drivers/net/hamradio/baycom_ser_hdx.c index f3d84911edcd..d2b82e589a5a 100644 --- a/drivers/net/hamradio/baycom_ser_hdx.c +++ b/drivers/net/hamradio/baycom_ser_hdx.c @@ -143,11 +143,6 @@ struct baycom_state { /* --------------------------------------------------------------------- */ -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#define max(a, b) (((a) > (b)) ? (a) : (b)) - -/* --------------------------------------------------------------------- */ - static void inline baycom_int_freq(struct baycom_state *bc) { #ifdef BAYCOM_DEBUG diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c index 7ff2c9cfae52..573203606027 100644 --- a/drivers/net/hamradio/hdlcdrv.c +++ b/drivers/net/hamradio/hdlcdrv.c @@ -95,11 +95,6 @@ static char ax25_nocall[AX25_ADDR_LEN] = #define PARAM_RETURN 255 /* --------------------------------------------------------------------- */ - -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#define max(a, b) (((a) > (b)) ? (a) : (b)) - -/* --------------------------------------------------------------------- */ /* * the CRC routines are stolen from WAMPES * by Dieter Deyke diff --git a/drivers/net/hamradio/soundmodem/sm.h b/drivers/net/hamradio/soundmodem/sm.h index 045e7e053402..367b045b8086 100644 --- a/drivers/net/hamradio/soundmodem/sm.h +++ b/drivers/net/hamradio/soundmodem/sm.h @@ -150,11 +150,6 @@ struct hardware_info { /* --------------------------------------------------------------------- */ -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#define max(a, b) (((a) > (b)) ? (a) : (b)) - -/* --------------------------------------------------------------------- */ - extern const char sm_drvname[]; extern const char sm_drvinfo[]; diff --git a/drivers/net/sk98lin/skproc.c b/drivers/net/sk98lin/skproc.c index 9c07f9c270bb..1abb4dd124bb 100644 --- a/drivers/net/sk98lin/skproc.c +++ b/drivers/net/sk98lin/skproc.c @@ -293,7 +293,7 @@ void *data) if (buffer_length >= len - offset) { *eof = 1; } - return (min(buffer_length, len - offset)); + return (min(int, buffer_length, len - offset)); } diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 230ae012f71e..b80a4d8a4a58 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c @@ -1,4 +1,4 @@ -/* $Id: sungem.c,v 1.18 2001/08/06 13:34:47 davem Exp $ +/* $Id: sungem.c,v 1.19 2001/08/13 14:40:07 davem Exp $ * sungem.c: Sun GEM ethernet driver. * * Copyright (C) 2000, 2001 David S. Miller (davem@redhat.com) @@ -558,7 +558,7 @@ static void gem_rx(struct gem *gp) skb = copy_skb; } - skb->csum = ((status & RXDCTRL_TCPCSUM) ^ 0xffff); + skb->csum = ntohs((status & RXDCTRL_TCPCSUM) ^ 0xffff); skb->ip_summed = CHECKSUM_HW; skb->protocol = eth_type_trans(skb, gp->dev); netif_rx(skb); diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index 42f737de5fd4..654e2db9256c 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c @@ -1,4 +1,4 @@ -/* $Id: sunhme.c,v 1.121 2001/07/27 10:22:57 davem Exp $ +/* $Id: sunhme.c,v 1.122 2001/08/13 14:40:07 davem Exp $ * sunhme.c: Sparc HME/BigMac 10/100baseT half/full duplex auto switching, * auto carrier detecting ethernet driver. Also known as the * "Happy Meal Ethernet" found on SunSwift SBUS cards. @@ -2109,7 +2109,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev) } /* This card is _fucking_ hot... */ - skb->csum = (csum ^ 0xffff); + skb->csum = ntohs(csum ^ 0xffff); skb->ip_summed = CHECKSUM_HW; RXD(("len=%d csum=%4x]", len, csum)); diff --git a/drivers/net/wan/comx-hw-comx.c b/drivers/net/wan/comx-hw-comx.c index e3b72a5af525..86737b11e28a 100644 --- a/drivers/net/wan/comx-hw-comx.c +++ b/drivers/net/wan/comx-hw-comx.c @@ -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(count, PAGE_SIZE)))) + if(copy_from_user(page, buffer, count = (min(int, count, PAGE_SIZE)))) { count = -EFAULT; goto out; @@ -1182,8 +1182,10 @@ 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(FILE_PAGESIZE, min(count, - hw->firmware ? (hw->firmware->len - off) : 0)); + len = min(int, FILE_PAGESIZE, + min(int, count, + hw->firmware ? + (hw->firmware->len - off) : 0)); if (len < 0) { len = 0; } @@ -1203,7 +1205,7 @@ static int comxhw_read_proc(char *page, char **start, off_t off, int count, if (count >= len - off) { *eof = 1; } - return(min(count, len - off)); + return min(int, count, len - off); } /* Called on echo comx >boardtype */ diff --git a/drivers/net/wan/comx-hw-locomx.c b/drivers/net/wan/comx-hw-locomx.c index 3714c6e60640..4b64939e864e 100644 --- a/drivers/net/wan/comx-hw-locomx.c +++ b/drivers/net/wan/comx-hw-locomx.c @@ -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(count, len - off) ); + return min(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(count, PAGE_SIZE)); + copy_from_user(page, buffer, count = min(unsigned long, count, PAGE_SIZE)); if (*(page + count - 1) == '\n') { *(page + count - 1) = 0; } diff --git a/drivers/net/wan/comx-hw-mixcom.c b/drivers/net/wan/comx-hw-mixcom.c index 8c367b5cca02..adf829894ff2 100644 --- a/drivers/net/wan/comx-hw-mixcom.c +++ b/drivers/net/wan/comx-hw-mixcom.c @@ -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(to_send, 32)); + &(hw->sending->data[hw->tx_ptr]), min(unsigned int, to_send, 32)); if (to_send <= 32) { hscx_cmd(dev, HSCX_XTF | HSCX_XME); kfree_skb(hw->sending); @@ -696,7 +696,7 @@ 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(count, len - off) ); + return min(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(count, PAGE_SIZE)); + copy_from_user(page, buffer, count = min(unsigned long, count, PAGE_SIZE)); if (*(page + count - 1) == '\n') { *(page + count - 1) = 0; } diff --git a/drivers/net/wan/comx-proto-fr.c b/drivers/net/wan/comx-proto-fr.c index 124c66e102f3..75ef5c56c9a4 100644 --- a/drivers/net/wan/comx-proto-fr.c +++ b/drivers/net/wan/comx-proto-fr.c @@ -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(count, len - off) ); + return min(int, count, len - off); } static int fr_write_proc(struct file *file, const char *buffer, diff --git a/drivers/net/wan/comx-proto-lapb.c b/drivers/net/wan/comx-proto-lapb.c index 64129018bdf1..520074f72f94 100644 --- a/drivers/net/wan/comx-proto-lapb.c +++ b/drivers/net/wan/comx-proto-lapb.c @@ -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(count, len - off) ); + return min(int, count, len - off); } static int comxlapb_write_proc(struct file *file, const char *buffer, diff --git a/drivers/net/wan/comx.c b/drivers/net/wan/comx.c index 8e76b39b9bd4..3d4986ea7ca1 100644 --- a/drivers/net/wan/comx.c +++ b/drivers/net/wan/comx.c @@ -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( free ? free : ch->debug_size, - min (ch->debug_size - ch->debug_end, len) ); + to_copy = min(int, free ? free : ch->debug_size, + min(int, ch->debug_size - ch->debug_end, len)); memcpy(ch->debug_area + ch->debug_end, str, to_copy); str += to_copy; len -= to_copy; @@ -567,7 +567,7 @@ static int comx_read_proc(char *page, char **start, off_t off, int count, if (count >= len - off) { *eof = 1; } - return( min(count, len - off) ); + return min(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(count, len - off) ); + return min(int, count, len - off); } diff --git a/drivers/net/wan/comx.h b/drivers/net/wan/comx.h index 1461d5fb18cb..0f7404f21470 100644 --- a/drivers/net/wan/comx.h +++ b/drivers/net/wan/comx.h @@ -190,14 +190,6 @@ struct comx_debugflags_struct { #endif -#ifndef min -#define min(a,b) ((a) > (b) ? (b) : (a)) -#endif -#ifndef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#endif - - #define COMX_CHANNEL(dev) ((struct comx_channel*)dev->priv) #define TWIN(dev) (COMX_CHANNEL(dev)->twin) diff --git a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c index 0c5e72d05d39..22ffa2e56a34 100644 --- a/drivers/net/wan/cycx_main.c +++ b/drivers/net/wan/cycx_main.c @@ -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(ncards, MAX_CARDS); - ncards = max(ncards, 1); + ncards = min(int, ncards, MAX_CARDS); + ncards = max(int, ncards, 1); card_array = kmalloc(sizeof(cycx_t) * ncards, GFP_KERNEL); if (!card_array) goto out; diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c index a65238c704b4..125a07b7eab2 100644 --- a/drivers/net/wan/cycx_x25.c +++ b/drivers/net/wan/cycx_x25.c @@ -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(conf->u.x25.hi_pvc, 4095); - card->u.x.lo_pvc = min(conf->u.x25.lo_pvc, card->u.x.hi_pvc); + card->u.x.hi_pvc = min(unsigned int, conf->u.x25.hi_pvc, 4095); + card->u.x.lo_pvc = min(unsigned int, conf->u.x25.lo_pvc, card->u.x.hi_pvc); } if (conf->u.x25.hi_svc) { - card->u.x.hi_svc = min(conf->u.x25.hi_svc, 4095); - card->u.x.lo_svc = min(conf->u.x25.lo_svc, card->u.x.hi_svc); + card->u.x.hi_svc = min(unsigned int, conf->u.x25.hi_svc, 4095); + card->u.x.lo_svc = min(unsigned int, conf->u.x25.lo_svc, card->u.x.hi_svc); } if (card->u.x.lo_pvc == 255) @@ -277,25 +277,25 @@ 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(conf->u.x25.hdlc_window, 7); + cfg.n2win = min(unsigned int, conf->u.x25.hdlc_window, 7); if (conf->u.x25.pkt_window) - cfg.n3win = min(conf->u.x25.pkt_window, 7); + cfg.n3win = min(unsigned int, conf->u.x25.pkt_window, 7); if (conf->u.x25.t1) - cfg.t1 = min(conf->u.x25.t1, 30); + cfg.t1 = min(unsigned int, conf->u.x25.t1, 30); if (conf->u.x25.t2) - cfg.t2 = min(conf->u.x25.t2, 30); + cfg.t2 = min(unsigned int, conf->u.x25.t2, 30); if (conf->u.x25.t11_t21) - cfg.t21 = min(conf->u.x25.t11_t21, 30); + cfg.t21 = min(unsigned int, conf->u.x25.t11_t21, 30); if (conf->u.x25.t13_t23) - cfg.t23 = min(conf->u.x25.t13_t23, 30); + cfg.t23 = min(unsigned int, conf->u.x25.t13_t23, 30); if (conf->u.x25.n2) - cfg.n2 = min(conf->u.x25.n2, 30); + cfg.n2 = min(unsigned int, conf->u.x25.n2, 30); /* initialize adapter */ if (x25_configure(card, &cfg)) diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c index 61c3f79f3ec8..3b3bd1707ac8 100644 --- a/drivers/net/wan/sbni.c +++ b/drivers/net/wan/sbni.c @@ -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( skb->len - nl->outpos, nl->framelen ); + unsigned len = min(unsigned int, skb->len - nl->outpos, nl->framelen); outsb( dev->base_addr + DAT, skb->data + nl->outpos, len ); *crc_p = calc_crc32( *crc_p, skb->data + nl->outpos, len ); @@ -760,8 +760,9 @@ interpret_ack( struct net_device *dev, unsigned ack ) nl->outpos += nl->framelen; if( --nl->tx_frameno ) - nl->framelen = min( nl->maxframe, - nl->tx_buf_p->len - nl->outpos ); + nl->framelen = min(unsigned int, + nl->maxframe, + nl->tx_buf_p->len - nl->outpos); else send_complete( nl ), #ifdef CONFIG_SBNI_MULTILINE diff --git a/drivers/net/wan/sbni.h b/drivers/net/wan/sbni.h index 335dbf13f4d6..8e83e274824d 100644 --- a/drivers/net/wan/sbni.h +++ b/drivers/net/wan/sbni.h @@ -137,7 +137,5 @@ struct sbni_flags { #define __initdata #endif -#define min( x, y ) ( (x) < (y) ? (x) : (y) ) - #endif diff --git a/drivers/net/wan/sdla_chdlc.c b/drivers/net/wan/sdla_chdlc.c index afd1fef9bc29..b5f027c17c41 100644 --- a/drivers/net/wan/sdla_chdlc.c +++ b/drivers/net/wan/sdla_chdlc.c @@ -505,13 +505,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(conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) : + min(unsigned int, conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) : CHDLC_DFLT_DATA_LEN; } else if(port_num == WANOPT_SEC) { /* For Secondary Port 1 */ card->wandev.mtu = (conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ? - min(conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) : + min(unsigned int, conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) : CHDLC_DFLT_DATA_LEN; } @@ -827,19 +827,19 @@ 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(conf->keepalive_tx_tmr,MAX_Tx_KPALV_TIMER) : + min(unsigned int, conf->keepalive_tx_tmr,MAX_Tx_KPALV_TIMER) : DEFAULT_Tx_KPALV_TIMER; card->u.c.kpalv_rx = ((conf->keepalive_rx_tmr - MIN_Rx_KPALV_TIMER) >= 0) ? - min(conf->keepalive_rx_tmr,MAX_Rx_KPALV_TIMER) : + min(unsigned int, conf->keepalive_rx_tmr,MAX_Rx_KPALV_TIMER) : DEFAULT_Rx_KPALV_TIMER; card->u.c.kpalv_err = ((conf->keepalive_err_margin-MIN_KPALV_ERR_TOL) >= 0) ? - min(conf->keepalive_err_margin, + min(unsigned int, conf->keepalive_err_margin, MAX_KPALV_ERR_TOL) : DEFAULT_KPALV_ERR_TOL; } @@ -847,7 +847,7 @@ 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 (conf->slarp_timer, MAX_SLARP_REQ_TIMER) : + min(unsigned int, conf->slarp_timer, MAX_SLARP_REQ_TIMER) : DEFAULT_SLARP_REQ_TIMER; #ifdef LINUX_2_0 diff --git a/drivers/net/wan/sdla_fr.c b/drivers/net/wan/sdla_fr.c index 4f5a9def99ae..1032346d596a 100644 --- a/drivers/net/wan/sdla_fr.c +++ b/drivers/net/wan/sdla_fr.c @@ -548,10 +548,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(conf->mtu, FR_MAX_NO_DATA_BYTES_IN_FRAME) : + min(unsigned int, conf->mtu, FR_MAX_NO_DATA_BYTES_IN_FRAME) : FR_CHANNEL_MTU + FR_HEADER_LEN; - conf->bps = min(conf->bps, 2048000); + conf->bps = min(unsigned int, conf->bps, 2048000); /* Initialze the configuration structure sent to the board to zero */ memset(&u.cfg, 0, sizeof(u.cfg)); @@ -618,7 +618,7 @@ int wpf_init(sdla_t *card, wandev_conf_t *conf) * command in fr_configure() routine. */ - card->u.f.dlci_num = min(max(conf->u.fr.dlci_num, 1), 100); + card->u.f.dlci_num = min(unsigned int, max(unsigned int, conf->u.fr.dlci_num, 1), 100); for ( i = 0; i < card->u.f.dlci_num; i++) { @@ -635,27 +635,27 @@ int wpf_init(sdla_t *card, wandev_conf_t *conf) u.cfg.port |= 0x0002; if (conf->u.fr.t391) - u.cfg.t391 = min(conf->u.fr.t391, 30); + u.cfg.t391 = min(unsigned int, conf->u.fr.t391, 30); else u.cfg.t391 = 5; if (conf->u.fr.t392) - u.cfg.t392 = min(conf->u.fr.t392, 30); + u.cfg.t392 = min(unsigned int, conf->u.fr.t392, 30); else u.cfg.t392 = 15; if (conf->u.fr.n391) - u.cfg.n391 = min(conf->u.fr.n391, 255); + u.cfg.n391 = min(unsigned int, conf->u.fr.n391, 255); else u.cfg.n391 = 2; if (conf->u.fr.n392) - u.cfg.n392 = min(conf->u.fr.n392, 10); + u.cfg.n392 = min(unsigned int, conf->u.fr.n392, 10); else u.cfg.n392 = 3; if (conf->u.fr.n393) - u.cfg.n393 = min(conf->u.fr.n393, 10); + u.cfg.n393 = min(unsigned int, conf->u.fr.n393, 10); else u.cfg.n393 = 4; @@ -952,7 +952,8 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf) */ if (conf->cir) { - chan->cir = max( 1, min( conf->cir, 512 ) ); + chan->cir = max(unsigned int, 1, + min(unsigned int, conf->cir, 512)); chan->cir_status = CIR_ENABLED; @@ -963,7 +964,8 @@ 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( 0, min( conf->be, 511) ); + chan->be = max(unsigned int, + 0, min(unsigned int, conf->be, 511)); }else{ conf->be = 0; } diff --git a/drivers/net/wan/sdla_ppp.c b/drivers/net/wan/sdla_ppp.c index 9af93fa18b69..00d53beb38d0 100644 --- a/drivers/net/wan/sdla_ppp.c +++ b/drivers/net/wan/sdla_ppp.c @@ -400,7 +400,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(conf->mtu, PPP_MAX_MTU) : PPP_DFLT_MTU; + min(unsigned int, conf->mtu, PPP_MAX_MTU) : PPP_DFLT_MTU; card->wandev.bps = conf->bps; card->wandev.interface = conf->interface; @@ -629,7 +629,7 @@ 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(dev->mtu, card->wandev.mtu); + dev->mtu = min(unsigned int, dev->mtu, card->wandev.mtu); /* Initialize the polling task routine */ #ifndef LINUX_2_4 diff --git a/drivers/net/wan/sdla_x25.c b/drivers/net/wan/sdla_x25.c index c60d00f68901..928327df0f22 100644 --- a/drivers/net/wan/sdla_x25.c +++ b/drivers/net/wan/sdla_x25.c @@ -653,13 +653,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(conf->u.x25.hi_pvc, MAX_LCN_NUM); - card->u.x.lo_pvc = min(conf->u.x25.lo_pvc, card->u.x.hi_pvc); + card->u.x.hi_pvc = min(unsigned int, conf->u.x25.hi_pvc, MAX_LCN_NUM); + card->u.x.lo_pvc = min(unsigned int, conf->u.x25.lo_pvc, card->u.x.hi_pvc); } if (conf->u.x25.hi_svc){ - card->u.x.hi_svc = min(conf->u.x25.hi_svc, MAX_LCN_NUM); - card->u.x.lo_svc = min(conf->u.x25.lo_svc, card->u.x.hi_svc); + card->u.x.hi_svc = min(unsigned int, conf->u.x25.hi_svc, MAX_LCN_NUM); + card->u.x.lo_svc = min(unsigned int, conf->u.x25.lo_svc, card->u.x.hi_svc); } /* Figure out the total number of channels to configure */ @@ -684,38 +684,38 @@ 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(conf->u.x25.hdlc_window, 7); + u.cfg.hdlcWindow = min(unsigned int, conf->u.x25.hdlc_window, 7); if (conf->u.x25.pkt_window) - u.cfg.pktWindow = min(conf->u.x25.pkt_window, 7); + u.cfg.pktWindow = min(unsigned int, conf->u.x25.pkt_window, 7); if (conf->u.x25.t1) - u.cfg.t1 = min(conf->u.x25.t1, 30); + u.cfg.t1 = min(unsigned int, conf->u.x25.t1, 30); if (conf->u.x25.t2) - u.cfg.t2 = min(conf->u.x25.t2, 29); + u.cfg.t2 = min(unsigned int, conf->u.x25.t2, 29); if (conf->u.x25.t4) - u.cfg.t4 = min(conf->u.x25.t4, 240); + u.cfg.t4 = min(unsigned int, conf->u.x25.t4, 240); if (conf->u.x25.n2) - u.cfg.n2 = min(conf->u.x25.n2, 30); + u.cfg.n2 = min(unsigned int, conf->u.x25.n2, 30); if (conf->u.x25.t10_t20) - u.cfg.t10t20 = min(conf->u.x25.t10_t20,255); + u.cfg.t10t20 = min(unsigned int, conf->u.x25.t10_t20,255); if (conf->u.x25.t11_t21) - u.cfg.t11t21 = min(conf->u.x25.t11_t21,255); + u.cfg.t11t21 = min(unsigned int, conf->u.x25.t11_t21,255); if (conf->u.x25.t12_t22) - u.cfg.t12t22 = min(conf->u.x25.t12_t22,255); + u.cfg.t12t22 = min(unsigned int, conf->u.x25.t12_t22,255); if (conf->u.x25.t13_t23) - u.cfg.t13t23 = min(conf->u.x25.t13_t23,255); + u.cfg.t13t23 = min(unsigned int, conf->u.x25.t13_t23,255); if (conf->u.x25.t16_t26) - u.cfg.t16t26 = min(conf->u.x25.t16_t26, 255); + u.cfg.t16t26 = min(unsigned int, conf->u.x25.t16_t26, 255); if (conf->u.x25.t28) - u.cfg.t28 = min(conf->u.x25.t28, 255); + u.cfg.t28 = min(unsigned int, conf->u.x25.t28, 255); if (conf->u.x25.r10_r20) - u.cfg.r10r20 = min(conf->u.x25.r10_r20,250); + u.cfg.r10r20 = min(unsigned int, conf->u.x25.r10_r20,250); if (conf->u.x25.r12_r22) - u.cfg.r12r22 = min(conf->u.x25.r12_r22,250); + u.cfg.r12r22 = min(unsigned int, conf->u.x25.r12_r22,250); if (conf->u.x25.r13_r23) - u.cfg.r13r23 = min(conf->u.x25.r13_r23,250); + u.cfg.r13r23 = min(unsigned int, conf->u.x25.r13_r23,250); if (conf->u.x25.ccitt_compat) diff --git a/drivers/net/wan/wanpipe_multppp.c b/drivers/net/wan/wanpipe_multppp.c index 448341d5bbd7..d190eb322e2c 100644 --- a/drivers/net/wan/wanpipe_multppp.c +++ b/drivers/net/wan/wanpipe_multppp.c @@ -375,13 +375,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(conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) : + min(unsigned int, conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) : CHDLC_DFLT_DATA_LEN; } else if(port_num == WANOPT_SEC) { /* For Secondary Port 1 */ card->wandev.mtu = (conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ? - min(conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) : + min(unsigned int, conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) : CHDLC_DFLT_DATA_LEN; } diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index ff2ac1ccd2d6..78b666462b01 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -259,8 +259,6 @@ MODULE_PARM_DESC(proc_perm, "The permission bits of the files in /proc"); #include <asm/uaccess.h> -#define min(x,y) ((x<y)?x:y) - /* This is a kind of sloppy hack to get this information to OUT4500 and IN4500. I would be extremely interested in the situation where this doesnt work though!!! */ @@ -1755,7 +1753,7 @@ 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(len, le16_to_cpu(*(u16*)pBuf)) - 2; + len = min(unsigned int, len, le16_to_cpu(*(u16*)pBuf)) - 2; if ( len <= 2 ) { printk( KERN_ERR @@ -3998,7 +3996,8 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { * 9/22/2000 Honor user given length */ - if (copy_to_user(comp->data, iobuf, min (comp->len, sizeof(iobuf)))) + if (copy_to_user(comp->data, iobuf, + min(unsigned int, comp->len, sizeof(iobuf)))) return -EFAULT; return 0; } @@ -4057,7 +4056,8 @@ 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(comp->len,sizeof(iobuf)))) + if (copy_to_user(comp->data, iobuf, + min(unsigned int, comp->len, sizeof(iobuf)))) return -EFAULT; return 0; diff --git a/drivers/net/wireless/airport.c b/drivers/net/wireless/airport.c index daa24801b818..3cd86b130d4a 100644 --- a/drivers/net/wireless/airport.c +++ b/drivers/net/wireless/airport.c @@ -1,4 +1,4 @@ -/* airport.c 0.05 +/* airport.c 0.06f * * A driver for "Hermes" chipset based Apple Airport wireless * card. @@ -32,6 +32,10 @@ #include "hermes.h" #include "orinoco.h" +static const char version[] __initdata = "airport.c 0.06f (Benjamin Herrenschmidt <benh@kernel.crashing.org>)"; +MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>"); +MODULE_DESCRIPTION("Driver for the Apple Airport wireless card."); + typedef struct dldwd_card { struct device_node* node; int irq_requested; @@ -40,8 +44,6 @@ typedef struct dldwd_card { struct dldwd_priv priv; } dldwd_card_t; -static char *version = "airport.c 0.05 (Benjamin Herrenschmidt <benh@kernel.crashing.org>)"; - /* * Function prototypes */ @@ -186,7 +188,7 @@ airport_attach(struct device_node* of_node) printk(KERN_ERR "airport: register_netdev() failed\n"); goto failed; } - printk(KERN_INFO "airport: card registered for interface %s\n", ndev->name); + printk(KERN_DEBUG "airport: card registered for interface %s\n", ndev->name); card->ndev_registered = 1; SET_MODULE_OWNER(ndev); @@ -242,7 +244,7 @@ init_airport(void) { struct device_node* airport_node; - printk(KERN_INFO "%s\n", version); + printk(KERN_DEBUG "%s\n", version); MOD_INC_USE_COUNT; diff --git a/drivers/net/wireless/hermes.c b/drivers/net/wireless/hermes.c index 923850119e41..c6a684b7a579 100644 --- a/drivers/net/wireless/hermes.c +++ b/drivers/net/wireless/hermes.c @@ -3,21 +3,19 @@ * Driver core for the "Hermes" wireless MAC controller, as used in * the Lucent Orinoco and Cabletron RoamAbout cards. It should also * work on the hfa3841 and hfa3842 MAC controller chips used in the - * Prism I & II chipsets. + * Prism II chipsets. * * This is not a complete driver, just low-level access routines for * the MAC controller itself. * * Based on the prism2 driver from Absolute Value Systems' linux-wlan * project, the Linux wvlan_cs driver, Lucent's HCF-Light - * (wvlan_hcf.c) library, and the NetBSD wireless driver. + * (wvlan_hcf.c) library, and the NetBSD wireless driver (in no + * particular order). * * Copyright (C) 2000, David Gibson, Linuxcare Australia <hermes@gibson.dropbear.id.au> * - * This file distributed under the GPL, version 2. - */ - -static const char *version = "hermes.c: 12 Dec 2000 David Gibson <hermes@gibson.dropbear.id.au>"; + * This file distributed under the GPL, version 2. */ #include <linux/module.h> #include <linux/types.h> @@ -32,6 +30,10 @@ static const char *version = "hermes.c: 12 Dec 2000 David Gibson <hermes@gibson. #include "hermes.h" +static const char version[] __initdata = "hermes.c: 1 Aug 2001 David Gibson <hermes@gibson.dropbear.id.au>"; +MODULE_DESCRIPTION("Low-level driver helper for Lucent Hermes chipset and Prism II HFA384x wireless MAC controller"); +MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>"); + /* These are maximum timeouts. Most often, card wil react much faster */ #define CMD_BUSY_TIMEOUT (100) /* In iterations of ~1us */ #define CMD_INIT_TIMEOUT (50000) /* in iterations of ~10us */ @@ -70,10 +72,6 @@ static const char *version = "hermes.c: 12 Dec 2000 David Gibson <hermes@gibson. static int hermes_issue_cmd(hermes_t *hw, uint16_t cmd, uint16_t param0); /* - * Internal inline functions - */ - -/* * Internal functions */ @@ -87,7 +85,6 @@ static int hermes_issue_cmd(hermes_t *hw, uint16_t cmd, uint16_t param0); static int hermes_issue_cmd(hermes_t *hw, uint16_t cmd, uint16_t param0) { uint16_t reg; -/* unsigned long k = CMD_BUSY_TIMEOUT; */ /* First check that the command register is not busy */ reg = hermes_read_regn(hw, CMD); @@ -124,9 +121,12 @@ int hermes_reset(hermes_t *hw) hermes_write_regn(hw, INTEN, 0); hermes_write_regn(hw, EVACK, 0xffff); - /* Because we hope we can reset the card even if it gets into - a stupid state, we actually wait to see if the command - register will unbusy itself */ + /* Normally it's a "can't happen" for the command register to + be busy when we go to issue a command because we are + serializing all commands. However we want to have some + chance of resetting the card even if it gets into a stupid + state, so we actually wait to see if the command register + will unbusy itself here. */ k = CMD_BUSY_TIMEOUT; reg = hermes_read_regn(hw, CMD); while (k && (reg & HERMES_CMD_BUSY)) { @@ -139,8 +139,8 @@ int hermes_reset(hermes_t *hw) reg = hermes_read_regn(hw, CMD); } - /* No need to explicitly handle the timeout - hermes_issue_cmd() will - probably return -EBUSY */ + /* No need to explicitly handle the timeout - if we've timed + out hermes_issue_cmd() will probably return -EBUSY below */ /* According to the documentation, EVSTAT may contain obsolete event occurrence information. We have to acknowledge @@ -503,7 +503,7 @@ EXPORT_SYMBOL(hermes_write_ltv); static int __init init_hermes(void) { - printk(KERN_INFO "%s\n", version); + printk(KERN_DEBUG "%s\n", version); return 0; } diff --git a/drivers/net/wireless/hermes.h b/drivers/net/wireless/hermes.h index 10c841316743..bc74036f247c 100644 --- a/drivers/net/wireless/hermes.h +++ b/drivers/net/wireless/hermes.h @@ -101,7 +101,7 @@ #define HERMES_STATUS_CMDCODE (0x003f) /* - * OFFSET refister bitmasks + * OFFSET register bitmasks */ #define HERMES_OFFSET_BUSY (0x8000) #define HERMES_OFFSET_ERR (0x4000) diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c index 76a913335ba9..2560a38c884d 100644 --- a/drivers/net/wireless/orinoco.c +++ b/drivers/net/wireless/orinoco.c @@ -1,4 +1,4 @@ -/* orinoco.c 0.06 - (formerly known as dldwd_cs.c and orinoco_cs.c) +/* orinoco.c 0.06f - (formerly known as dldwd_cs.c and orinoco_cs.c) * * A driver for "Hermes" chipset based PCMCIA wireless adaptors, such * as the Lucent WavelanIEEE/Orinoco cards and their OEM (Cabletron/ @@ -33,10 +33,10 @@ * Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the above. - * If you wish to allow the use of your version of this file only - * under the terms of the GPL and not to allow others to use your + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the + * above. If you wish to allow the use of your version of this file + * only under the terms of the GPL and not to allow others to use your * version of this file under the MPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the GPL. If you do not delete the @@ -166,6 +166,24 @@ * v0.06b -> v0.06c - 29/5/2001 - Jean II * o Show first spy address in /proc/net/wireless for IBSS mode as well * + * v0.06c -> v0.06d - 6/7/2001 - David Gibson + * o Change a bunch of KERN_INFO messages to KERN_DEBUG, as per Linus' + * wishes to reduce the number of unecessary messages. + * o Removed bogus message on CRC error. + * o Merged fixeds for v0.08 Prism 2 firmware from William Waghorn + * <willwaghorn@yahoo.co.uk> + * o Slight cleanup/re-arrangement of firmware detection code. + * + * v0.06d -> v0.06e - 1/8/2001 - David Gibson + * o Removed some redundant global initializers (orinoco_cs.c). + * o Added some module metadataa + * + * v0.06e -> v0.06f - 14/8/2001 - David Gibson + * o Wording fix to license + * o Added a 'use_alternate_encaps' module parameter for APs which need an oui of + * 00:00:00. We really need a better way of handling this, but the module flag + * is better than nothing for now. + * * TODO - Jean II * o inline functions (lot's of candidate, need to reorder code) * o Test PrismII/Symbol cards & firmware versions @@ -202,7 +220,9 @@ #include "hermes.h" #include "orinoco.h" -static char *version = "orinoco.c 0.06c (David Gibson <hermes@gibson.dropbear.id.au> and others)"; +static const char version[] __initdata = "orinoco.c 0.06f (David Gibson <hermes@gibson.dropbear.id.au> and others)"; +MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>"); +MODULE_DESCRIPTION("Driver for Lucent Orinoco, Prism II based and similar wireless cards"); /* Level of debugging. Used in the macros in orinoco.h */ #ifdef ORINOCO_DEBUG @@ -210,6 +230,11 @@ int dldwd_debug = ORINOCO_DEBUG; MODULE_PARM(dldwd_debug, "i"); #endif +/* FIXME: We need a better way of handling this */ +/* Set this flag to use 00:00:00 for the encapsulation oui instead of 00:00:F8 */ +static int use_alternate_encaps; /* =0 */ +MODULE_PARM(use_alternate_encaps, "i"); + const long channel_frequency[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484 @@ -274,6 +299,9 @@ struct dldwd_frame_hdr { struct p8022_hdr encaps_hdr = { 0xaa, 0xaa, 0x03, {0x00, 0x00, 0xf8} }; +struct p8022_hdr alternate_encaps_hdr = { + 0xaa, 0xaa, 0x03, {0x00, 0x00, 0x00} +}; /* * Function prototypes @@ -396,6 +424,7 @@ set_port_type(dldwd_priv_t *priv) priv->port_type = 4; else priv->port_type = 1; + priv->port_type = priv->ibss_port; priv->allow_ibss = 1; } break; @@ -1050,8 +1079,7 @@ static void __dldwd_ev_rx(dldwd_priv_t *priv, hermes_t *hw) if (status & HERMES_RXSTAT_ERR) { if ((status & HERMES_RXSTAT_ERR) == HERMES_RXSTAT_BADCRC) { stats->rx_crc_errors++; - printk(KERN_WARNING "%s: Bad CRC on Rx. Frame dropped.\n", - dev->name); + DEBUG(1, "%s: Bad CRC on Rx. Frame dropped.\n", dev->name); show_rx_frame(&hdr); } else if ((status & HERMES_RXSTAT_ERR) == HERMES_RXSTAT_UNDECRYPTABLE) { @@ -1198,34 +1226,14 @@ static void __dldwd_ev_alloc(dldwd_priv_t *priv, hermes_t *hw) /* hermes_write_regn(hw, ALLOCFID, 0); */ } -/* - * struct net_device methods - */ - -int -dldwd_init(struct net_device *dev) +static void determine_firmware(struct net_device *dev) { dldwd_priv_t *priv = dev->priv; hermes_t *hw = &priv->hw; - int err = 0; - hermes_id_t nickbuf; - uint16_t reclen; - int len; - char *vendor_str; + int err; uint32_t firmver; + char *vendor_str; - TRACE_ENTER("dldwd"); - - dldwd_lock(priv); - - /* Do standard firmware reset */ - err = hermes_reset(hw); - if (err != 0) { - printk(KERN_ERR "%s: failed to reset hardware (err = %d)\n", - dev->name, err); - goto out; - } - /* Get the firmware version */ err = hermes_read_staidentity(hw, USER_BAP, &priv->firmware_info); if (err) { @@ -1361,18 +1369,54 @@ dldwd_init(struct net_device *dev) priv->has_pm = 0; priv->has_preamble = 0; } + + if (priv->firmware_type == FIRMWARE_TYPE_SYMBOL) + priv->ibss_port = 4; + else if ( (priv->firmware_type == FIRMWARE_TYPE_PRISM2) && (firmver >= 0x00008) ) + priv->ibss_port = 0; + else + priv->ibss_port = 1; - printk(KERN_INFO "%s: Firmware ID %02X vendor 0x%x (%s) version %d.%02d\n", + printk(KERN_DEBUG "%s: Firmware ID %02X vendor 0x%x (%s) version %d.%02d\n", dev->name, priv->firmware_info.id, priv->firmware_info.vendor, vendor_str, priv->firmware_info.major, priv->firmware_info.minor); +} + +/* + * struct net_device methods + */ + +int +dldwd_init(struct net_device *dev) +{ + dldwd_priv_t *priv = dev->priv; + hermes_t *hw = &priv->hw; + int err = 0; + hermes_id_t nickbuf; + uint16_t reclen; + int len; + + TRACE_ENTER("dldwd"); + + dldwd_lock(priv); + + /* Do standard firmware reset */ + err = hermes_reset(hw); + if (err != 0) { + printk(KERN_ERR "%s: failed to reset hardware (err = %d)\n", + dev->name, err); + goto out; + } + + determine_firmware(dev); if (priv->has_port3) - printk(KERN_INFO "%s: Ad-hoc demo mode supported.\n", dev->name); + printk(KERN_DEBUG "%s: Ad-hoc demo mode supported.\n", dev->name); if (priv->has_ibss) - printk(KERN_INFO "%s: IEEE standard IBSS ad-hoc mode supported.\n", + printk(KERN_DEBUG "%s: IEEE standard IBSS ad-hoc mode supported.\n", dev->name); if (priv->has_wep) { - printk(KERN_INFO "%s: WEP supported, ", dev->name); + printk(KERN_DEBUG "%s: WEP supported, ", dev->name); if (priv->has_big_wep) printk("\"128\"-bit key.\n"); else @@ -1388,7 +1432,7 @@ dldwd_init(struct net_device *dev) goto out; } - printk(KERN_INFO "%s: MAC address %02X:%02X:%02X:%02X:%02X:%02X\n", + printk(KERN_DEBUG "%s: MAC address %02X:%02X:%02X:%02X:%02X:%02X\n", dev->name, dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); @@ -1408,7 +1452,7 @@ dldwd_init(struct net_device *dev) memcpy(priv->nick, &nickbuf.val, len); priv->nick[len] = '\0'; - printk(KERN_INFO "%s: Station name \"%s\"\n", dev->name, priv->nick); + printk(KERN_DEBUG "%s: Station name \"%s\"\n", dev->name, priv->nick); /* Get allowed channels */ err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNEL_LIST, &priv->channel_mask); @@ -1482,7 +1526,7 @@ dldwd_init(struct net_device *dev) priv->wep_on = 0; priv->tx_key = 0; - printk(KERN_INFO "%s: ready\n", dev->name); + printk(KERN_DEBUG "%s: ready\n", dev->name); out: dldwd_unlock(priv); @@ -1668,7 +1712,11 @@ dldwd_xmit(struct sk_buff *skb, struct net_device *dev) hdr.p8023.h_proto = htons(data_len + ENCAPS_OVERHEAD); /* 802.2 header */ - memcpy(&hdr.p8022, &encaps_hdr, sizeof(encaps_hdr)); + /* FIXME: ugh, what a hack for the 00:00:00 APs. Need to find a better way */ + if (use_alternate_encaps) + memcpy(&hdr.p8022, &alternate_encaps_hdr, sizeof(alternate_encaps_hdr)); + else + memcpy(&hdr.p8022, &encaps_hdr, sizeof(encaps_hdr)); hdr.ethertype = eh->h_proto; err = hermes_bap_pwrite(hw, USER_BAP, &hdr, sizeof(hdr), @@ -2546,6 +2594,33 @@ static int dldwd_ioctl_getretry(struct net_device *dev, struct iw_param *rrq) } #endif /* WIRELESS_EXT > 10 */ +static int dldwd_ioctl_setibssport(struct net_device *dev, struct iwreq *wrq) +{ + dldwd_priv_t *priv = dev->priv; + int val = *( (int *) wrq->u.name ); + + dldwd_lock(priv); + priv->ibss_port = val ; + + /* Actually update the mode we are using */ + set_port_type(priv); + + dldwd_unlock(priv); + return 0; +} + +static int dldwd_ioctl_getibssport(struct net_device *dev, struct iwreq *wrq) +{ + dldwd_priv_t *priv = dev->priv; + int *val = (int *)wrq->u.name; + + dldwd_lock(priv); + *val = priv->ibss_port; + dldwd_unlock(priv); + + return 0; +} + static int dldwd_ioctl_setport3(struct net_device *dev, struct iwreq *wrq) { dldwd_priv_t *priv = dev->priv; @@ -2941,7 +3016,13 @@ dldwd_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 0, "set_preamble" }, { SIOCDEVPRIVATE + 0x5, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, - "get_preamble" } + "get_preamble" }, + { SIOCDEVPRIVATE + 0x6, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + 0, "set_ibssport" }, + { SIOCDEVPRIVATE + 0x7, 0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "get_ibssport" } }; err = verify_area(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)); @@ -3038,6 +3119,25 @@ dldwd_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } else err = -EOPNOTSUPP; break; + case SIOCDEVPRIVATE + 0x6: /* set_ibssport */ + DEBUG(1, "%s: SIOCDEVPRIVATE + 0x6 (set_ibssport)\n", + dev->name); + if (! capable(CAP_NET_ADMIN)) { + err = -EPERM; + break; + } + + err = dldwd_ioctl_setibssport(dev, wrq); + if (! err) + changed = 1; + break; + + case SIOCDEVPRIVATE + 0x7: /* get_ibssport */ + DEBUG(1, "%s: SIOCDEVPRIVATE + 0x7 (get_ibssport)\n", + dev->name); + err = dldwd_ioctl_getibssport(dev, wrq); + break; + default: err = -EOPNOTSUPP; @@ -3601,7 +3701,7 @@ static int __init init_dldwd(void) err = dldwd_proc_init(); - printk(KERN_INFO "%s\n", version); + printk(KERN_DEBUG "%s\n", version); return 0; } diff --git a/drivers/net/wireless/orinoco.h b/drivers/net/wireless/orinoco.h index b90d323d2fa1..db2b6638cc4a 100644 --- a/drivers/net/wireless/orinoco.h +++ b/drivers/net/wireless/orinoco.h @@ -69,7 +69,7 @@ typedef struct dldwd_priv { #define FIRMWARE_TYPE_LUCENT 1 #define FIRMWARE_TYPE_PRISM2 2 #define FIRMWARE_TYPE_SYMBOL 3 - int has_ibss, has_port3, prefer_port3, has_ibss_any; + int has_ibss, has_port3, prefer_port3, has_ibss_any, ibss_port; int has_wep, has_big_wep; int has_mwo; int has_pm; @@ -107,10 +107,10 @@ typedef struct dldwd_priv { /*====================================================================*/ -extern int dldwd_debug; extern struct list_head dldwd_instances; #ifdef ORINOCO_DEBUG +extern int dldwd_debug; #define DEBUG(n, args...) if (dldwd_debug>(n)) printk(KERN_DEBUG args) #define DEBUGMORE(n, args...) do { if (dldwd_debug>(n)) printk(args); } while (0) #else diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index 8bf94dc46acd..2a26a07c4c1c 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -1,4 +1,4 @@ -/* orinoco_cs.c 0.06 - (formerly known as dldwd_cs.c) +/* orinoco_cs.c 0.06f - (formerly known as dldwd_cs.c) * * A driver for "Hermes" chipset based PCMCIA wireless adaptors, such * as the Lucent WavelanIEEE/Orinoco cards and their OEM (Cabletron/ @@ -40,20 +40,12 @@ #include "hermes.h" #include "orinoco.h" -/* Pcmcia specific structure */ -typedef struct dldwd_card { - dev_link_t link; - dev_node_t node; - int instance; - - /* Common structure (fully included), see orinoco.h */ - struct dldwd_priv priv; -} dldwd_card_t; +/*====================================================================*/ -static char version[] __initdata = -"orinoco_cs.c 0.06 (David Gibson <hermes@gibson.dropbear.id.au> and others)"; +static const char version[] __initdata = "orinoco_cs.c 0.06f (David Gibson <hermes@gibson.dropbear.id.au> and others)"; -/*====================================================================*/ +MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>"); +MODULE_DESCRIPTION("Driver for PCMCIA Lucent Orinoco, Prism II based and similar wireless cards"); /* Parameters that can be set with 'insmod' */ @@ -66,13 +58,24 @@ static int irq_list[4] = { -1 }; static int reset_cor = 0; /* Some D-Link cards have buggy CIS. They do work at 5v properly, but * don't have any CIS entry for it. This workaround it... */ -static int ignore_cis_vcc = 0; +static int ignore_cis_vcc; /* = 0 */ MODULE_PARM(irq_mask, "i"); MODULE_PARM(irq_list, "1-4i"); MODULE_PARM(reset_cor, "i"); MODULE_PARM(ignore_cis_vcc, "i"); + +/* Pcmcia specific structure */ +typedef struct dldwd_card { + dev_link_t link; + dev_node_t node; + int instance; + + /* Common structure (fully included), see orinoco.h */ + struct dldwd_priv priv; +} dldwd_card_t; + /* * Function prototypes */ @@ -108,8 +111,8 @@ static dev_info_t dev_info = "orinoco_cs"; device numbers are used to derive the corresponding array index. */ -static dev_link_t *dev_list; -static int num_instances; +static dev_link_t *dev_list; /* = NULL */ +static int num_instances; /* = 0 */ /*====================================================================*/ @@ -595,7 +598,7 @@ dldwd_cs_config(dev_link_t * link) strcpy(card->node.dev_name, ndev->name); /* Finally, report what we've done */ - printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", + printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d", ndev->name, link->conf.ConfigIndex, link->conf.Vcc / 10, link->conf.Vcc % 10); if (link->conf.Vpp1) @@ -777,8 +780,8 @@ init_dldwd_cs(void) TRACE_ENTER("dldwd"); - printk(KERN_INFO "dldwd: David's Less Dodgy WaveLAN/IEEE Driver\n" - KERN_INFO "%s\n", version); + printk(KERN_DEBUG "dldwd: David's Less Dodgy WaveLAN/IEEE Driver\n" + KERN_DEBUG "%s\n", version); CardServices(GetCardServicesInfo, &serv); if (serv.Revision != CS_RELEASE_CODE) { diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c index 4f1caa5210eb..8b6b662f1124 100644 --- a/drivers/s390/net/iucv.c +++ b/drivers/s390/net/iucv.c @@ -39,13 +39,6 @@ #include <asm/s390_ext.h> #include <asm/ebcdic.h> -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef max -#define max(a,b) (((a)>(b))?(a):(b)) -#endif - #ifdef DEBUG #undef KERN_INFO #undef KERN_DEBUG @@ -1316,7 +1309,7 @@ iucv_receive (u16 pathid, u32 msgid, u32 trgcls, if (residual_buffer) *residual_buffer = parm.ipbfadr1; } else { - moved = min (buflen, 8); + moved = min(unsigned int, buflen, 8); memcpy ((char *) buffer, (char *) &parm.ipbfadr1, moved); @@ -1409,7 +1402,8 @@ iucv_receive_array (u16 pathid, while ((moved < 8) && (moved < buflen)) { dyn_len = - min ((buffer + i)->length, need_to_move); + min(unsigned int, + (buffer + i)->length, need_to_move); memcpy ((char *)((ulong)((buffer + i)->address)), ((char *) &parm.ipbfadr1) + moved, diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c index da068f42a517..09660e03ac75 100644 --- a/drivers/s390/net/netiucv.c +++ b/drivers/s390/net/netiucv.c @@ -91,7 +91,6 @@ MODULE_PARM_DESC (iucv, #include <linux/init.h> /* __setup() */ #include <asm/string.h> /* memset, memcpy, etc. */ #include "iucv.h" -#define min(a,b) (a < b) ? a : b #if defined( DEBUG ) #undef KERN_INFO @@ -828,7 +827,8 @@ register_iucv_dev (int devnumber, char *userid) net_device *dev; memset (iucv_userid[devnumber], ' ', 8); - memcpy (iucv_userid[devnumber], userid, min (strlen (userid), 8)); + memcpy (iucv_userid[devnumber], userid, + min(unsigned int, strlen(userid), 8)); dev = &iucv_netdev[devnumber]; sprintf (dev->name, "iucv%i", devnumber); diff --git a/drivers/sbus/audio/audio.c b/drivers/sbus/audio/audio.c index 581bdc847c2c..e8d9daca2de7 100644 --- a/drivers/sbus/audio/audio.c +++ b/drivers/sbus/audio/audio.c @@ -1,4 +1,4 @@ -/* $Id: audio.c,v 1.60 2001/05/21 09:05:05 davem Exp $ +/* $Id: audio.c,v 1.61 2001/08/13 14:40:12 davem Exp $ * drivers/sbus/audio/audio.c * * Copyright 1996 Thomas K. Dyas (tdyas@noc.rutgers.edu) diff --git a/drivers/sbus/char/aurora.c b/drivers/sbus/char/aurora.c index 0d7cf3557ed0..1e43c35111b8 100644 --- a/drivers/sbus/char/aurora.c +++ b/drivers/sbus/char/aurora.c @@ -1,4 +1,4 @@ -/* $Id: aurora.c,v 1.14 2001/06/29 23:07:37 davem Exp $ +/* $Id: aurora.c,v 1.15 2001/08/13 14:40:08 davem Exp $ * linux/drivers/sbus/char/aurora.c -- Aurora multiport driver * * Copyright (c) 1999 by Oliver Aldulea (oli at bv dot ro) diff --git a/drivers/sbus/char/pcikbd.c b/drivers/sbus/char/pcikbd.c index 4163a131cad2..dd650c6836fe 100644 --- a/drivers/sbus/char/pcikbd.c +++ b/drivers/sbus/char/pcikbd.c @@ -1,4 +1,4 @@ -/* $Id: pcikbd.c,v 1.58 2001/06/10 06:51:03 davem Exp $ +/* $Id: pcikbd.c,v 1.59 2001/08/13 14:40:08 davem Exp $ * pcikbd.c: Ultra/AX PC keyboard support. * * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) @@ -478,6 +478,11 @@ void pcikbd_leds(unsigned char leds) send_data(KBD_CMD_ENABLE); } +int pcikbd_rate(struct kbd_repeat *rep) +{ + return -EIO; +} + static int pcikbd_wait_for_input(void) { int status, data; diff --git a/drivers/sbus/char/rtc.c b/drivers/sbus/char/rtc.c index f380538c14c5..37fd2110a0f5 100644 --- a/drivers/sbus/char/rtc.c +++ b/drivers/sbus/char/rtc.c @@ -1,4 +1,4 @@ -/* $Id: rtc.c,v 1.26 2001/03/14 09:30:31 davem Exp $ +/* $Id: rtc.c,v 1.27 2001/08/13 14:40:08 davem Exp $ * * Linux/SPARC Real Time Clock Driver * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu) diff --git a/drivers/sbus/char/uctrl.c b/drivers/sbus/char/uctrl.c index 01739b537c56..3a12bbe10031 100644 --- a/drivers/sbus/char/uctrl.c +++ b/drivers/sbus/char/uctrl.c @@ -1,4 +1,4 @@ -/* $Id: uctrl.c,v 1.10 2001/02/13 01:17:00 davem Exp $ +/* $Id: uctrl.c,v 1.11 2001/08/13 14:40:08 davem Exp $ * uctrl.c: TS102 Microcontroller interface on Tadpole Sparcbook 3 * * Copyright 1999 Derrick J Brashear (shadow@dementia.org) diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 3ab0811a8e57..d748be4e4fb1 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -1202,15 +1202,14 @@ static void tw_interrupt(int irq, void *dev_instance, struct pt_regs *regs) int do_attention_interrupt=0; int do_host_interrupt=0; int do_command_interrupt=0; - int flags = 0; - int flags2 = 0; + unsigned long flags = 0; TW_Command *command_packet; if (test_and_set_bit(TW_IN_INTR, &tw_dev->flags)) return; spin_lock_irqsave(&io_request_lock, flags); if (tw_dev->tw_pci_dev->irq == irq) { - spin_lock_irqsave(&tw_dev->tw_lock, flags2); + spin_lock(&tw_dev->tw_lock); dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt()\n"); /* Read the registers */ @@ -1349,7 +1348,7 @@ static void tw_interrupt(int irq, void *dev_instance, struct pt_regs *regs) } } } - spin_unlock_irqrestore(&tw_dev->tw_lock, flags2); + spin_unlock(&tw_dev->tw_lock); } spin_unlock_irqrestore(&io_request_lock, flags); clear_bit(TW_IN_INTR, &tw_dev->flags); @@ -1918,7 +1917,7 @@ int tw_scsi_queue(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) unsigned char *command = SCpnt->cmnd; int request_id = 0; int error = 0; - int flags = 0; + unsigned long flags = 0; TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->host->hostdata; if (tw_dev == NULL) { diff --git a/drivers/scsi/eata_generic.h b/drivers/scsi/eata_generic.h index c884def02a2f..b25cfbf9e7b3 100644 --- a/drivers/scsi/eata_generic.h +++ b/drivers/scsi/eata_generic.h @@ -25,8 +25,6 @@ #define FALSE 0 #endif -#define min(a,b) ((a<b)?(a):(b)) - #define R_LIMIT 0x20000 #define MAXISA 4 diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c index ce5b3800106e..7a070be69aa4 100644 --- a/drivers/scsi/eata_pio.c +++ b/drivers/scsi/eata_pio.c @@ -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(z,cmd->SCp.this_residual/2); + x=min(unsigned int,z,cmd->SCp.this_residual/2); insw(base+HA_RDATA,cmd->SCp.ptr,x); z-=x; IncStat(&cmd->SCp,2*x); @@ -191,7 +191,7 @@ void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs * regs) z--; odd=FALSE; } - x=min(z,cmd->SCp.this_residual/2); + x=min(unsigned int,z,cmd->SCp.this_residual/2); outsw(base+HA_RDATA,cmd->SCp.ptr,x); z-=x; IncStat(&cmd->SCp,2*x); diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index d75f0f29e589..f8f37161b838 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -1416,7 +1416,7 @@ int ips_eh_reset(Scsi_Cmnd *SC) { int ret; int i; - u32 cpu_flags; + unsigned long cpu_flags; ips_ha_t *ha; ips_scb_t *scb; ips_copp_wait_item_t *item; @@ -1607,7 +1607,7 @@ ips_eh_reset(Scsi_Cmnd *SC) { int ips_queue(Scsi_Cmnd *SC, void (*done) (Scsi_Cmnd *)) { ips_ha_t *ha; - u32 cpu_flags; + unsigned long cpu_flags; DECLARE_MUTEX_LOCKED(sem); METHOD_TRACE("ips_queue", 1); @@ -1854,7 +1854,7 @@ ips_select_queue_depth(struct Scsi_Host *host, Scsi_Device *scsi_devs) { void do_ipsintr(int irq, void *dev_id, struct pt_regs *regs) { ips_ha_t *ha; - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("do_ipsintr", 2); @@ -1909,7 +1909,7 @@ ips_intr_copperhead(ips_ha_t *ha) { ips_scb_t *scb; IPS_STATUS cstatus; int intrstatus; - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_intr", 2); @@ -1981,7 +1981,7 @@ ips_intr_morpheus(ips_ha_t *ha) { ips_scb_t *scb; IPS_STATUS cstatus; int intrstatus; - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_intr_morpheus", 2); @@ -3548,8 +3548,8 @@ ips_next(ips_ha_t *ha, int intr) { ips_copp_wait_item_t *item; int ret; int intr_status; - u32 cpu_flags; - u32 cpu_flags2; + unsigned long cpu_flags; + unsigned long cpu_flags2; METHOD_TRACE("ips_next", 1); @@ -4403,7 +4403,7 @@ ipsintr_done(ips_ha_t *ha, ips_scb_t *scb) { static void ips_done(ips_ha_t *ha, ips_scb_t *scb) { int ret; - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_done", 1); @@ -5520,7 +5520,7 @@ ips_init_scb(ips_ha_t *ha, ips_scb_t *scb) { static ips_scb_t * ips_getscb(ips_ha_t *ha) { ips_scb_t *scb; - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_getscb", 1); @@ -5554,7 +5554,7 @@ ips_getscb(ips_ha_t *ha) { /****************************************************************************/ static void ips_freescb(ips_ha_t *ha, ips_scb_t *scb) { - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_freescb", 1); @@ -5967,7 +5967,7 @@ ips_init_morpheus(ips_ha_t *ha) { static int ips_reset_copperhead(ips_ha_t *ha) { int reset_counter; - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_reset_copperhead", 1); @@ -6012,7 +6012,7 @@ ips_reset_copperhead(ips_ha_t *ha) { static int ips_reset_copperhead_memio(ips_ha_t *ha) { int reset_counter; - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_reset_copperhead_memio", 1); @@ -6058,7 +6058,7 @@ static int ips_reset_morpheus(ips_ha_t *ha) { int reset_counter; u8 junk; - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_reset_morpheus", 1); @@ -6237,7 +6237,7 @@ static int ips_issue_copperhead(ips_ha_t *ha, ips_scb_t *scb) { u32 TimeOut; u16 val; - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_issue_copperhead", 1); @@ -6300,7 +6300,7 @@ static int ips_issue_copperhead_memio(ips_ha_t *ha, ips_scb_t *scb) { u32 TimeOut; u32 val; - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_issue_copperhead_memio", 1); @@ -6361,7 +6361,7 @@ ips_issue_copperhead_memio(ips_ha_t *ha, ips_scb_t *scb) { /****************************************************************************/ static int ips_issue_i2o(ips_ha_t *ha, ips_scb_t *scb) { - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_issue_i2o", 1); @@ -6401,7 +6401,7 @@ ips_issue_i2o(ips_ha_t *ha, ips_scb_t *scb) { /****************************************************************************/ static int ips_issue_i2o_memio(ips_ha_t *ha, ips_scb_t *scb) { - u32 cpu_flags; + unsigned long cpu_flags; METHOD_TRACE("ips_issue_i2o_memio", 1); diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index e3af0dbcfc29..dc4681cd4d7c 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -34,8 +34,6 @@ #define MAX_BUF PAGE_SIZE -#define max(a,b) (((a) > (b)) ? (a) : (b)) - /* * If we are told to probe a host, we will return 0 if the host is not * present, 1 if the host is present, and will return an identifying diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index 65439514eece..6abdd0360e6c 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -545,7 +545,7 @@ int sr_dev_ioctl(struct cdrom_device_info *cdi, switch (cmd) { case BLKGETSIZE: - return put_user(scsi_CDs[target].capacity >> 1, (long *) arg); + return put_user(scsi_CDs[target].capacity, (long *) arg); case BLKROSET: case BLKROGET: case BLKRASET: diff --git a/drivers/sound/btaudio.c b/drivers/sound/btaudio.c index 66cf93a9aa3a..f52500046f3f 100644 --- a/drivers/sound/btaudio.c +++ b/drivers/sound/btaudio.c @@ -32,7 +32,9 @@ #include <linux/poll.h> #include <linux/sound.h> #include <linux/soundcard.h> +#include <linux/slab.h> #include <asm/uaccess.h> +#include <asm/io.h> /* mmio access */ @@ -850,7 +852,7 @@ static int __devinit btaudio_probe(struct pci_dev *pci_dev, /* init hw */ btwrite(0, REG_GPIO_DMA_CTL); btwrite(0, REG_INT_MASK); - btwrite(~0x0UL, REG_INT_STAT); + btwrite(~(u32)0x0, REG_INT_STAT); pci_set_master(pci_dev); if ((rc = request_irq(bta->irq, btaudio_irq, SA_SHIRQ|SA_INTERRUPT, @@ -902,7 +904,7 @@ static void __devexit btaudio_remove(struct pci_dev *pci_dev) /* turn off all DMA / IRQs */ btand(~15, REG_GPIO_DMA_CTL); btwrite(0, REG_INT_MASK); - btwrite(~0x0UL, REG_INT_STAT); + btwrite(~(u32)0x0, REG_INT_STAT); /* unregister devices */ unregister_sound_dsp(bta->dsp_dev); diff --git a/drivers/sound/dmasound/dmasound.h b/drivers/sound/dmasound/dmasound.h index ff799552269d..7d77b9f7ae41 100644 --- a/drivers/sound/dmasound/dmasound.h +++ b/drivers/sound/dmasound/dmasound.h @@ -47,7 +47,6 @@ #define MAX_BUFSIZE 128 /* Limit for Amiga in KB */ -#define min(x, y) ((x) < (y) ? (x) : (y)) #define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff)) #define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff)) diff --git a/drivers/sound/dmasound/dmasound_atari.c b/drivers/sound/dmasound/dmasound_atari.c index 0845ecd522ba..619a3e874c28 100644 --- a/drivers/sound/dmasound/dmasound_atari.c +++ b/drivers/sound/dmasound/dmasound_atari.c @@ -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(userCount, frameLeft); + count = min(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(userCount, frameLeft); + count = min(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(userCount, frameLeft); + count = min(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(userCount, frameLeft)>>1; + count = min(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(userCount, frameLeft)>>1; + count = min(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(userCount, frameLeft) & ~3; + count = min(unsigned long, userCount, frameLeft) & ~3; used = count; if (copy_from_user(p, userPtr, count)) return -EFAULT; @@ -261,7 +261,7 @@ 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(userCount, frameLeft)>>1; + count = min(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(userCount, frameLeft)>>2; + count = min(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(userCount, frameLeft)>>1; + count = min(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(userCount, frameLeft)>>2; + count = min(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(userCount, frameLeft)>>1; + count = min(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(userCount, frameLeft)>>2; + count = min(unsigned long, userCount, frameLeft)>>2; used = count; while (count > 0) { u_long data; diff --git a/drivers/sound/dmasound/dmasound_awacs.c b/drivers/sound/dmasound/dmasound_awacs.c index 2f85ffc27234..9143101a52ea 100644 --- a/drivers/sound/dmasound/dmasound_awacs.c +++ b/drivers/sound/dmasound/dmasound_awacs.c @@ -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(userCount, frameLeft); + used = count = min(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(userCount, frameLeft); + used = count = min(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(userCount, frameLeft); + used = count = min(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(userCount, frameLeft); + used = count = min(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(userCount, frameLeft); + used = count = min(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(userCount, frameLeft); + used = count = min(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(userCount, frameLeft); + used = count = min(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(userCount, frameLeft); + used = count = min(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(userCount, frameLeft); + used = count = min(unsigned long, userCount, frameLeft); while (count > 0) { int data; diff --git a/drivers/sound/dmasound/dmasound_paula.c b/drivers/sound/dmasound/dmasound_paula.c index d76c079371d2..1ec6382759e5 100644 --- a/drivers/sound/dmasound/dmasound_paula.c +++ b/drivers/sound/dmasound/dmasound_paula.c @@ -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(userCount, frameLeft) & ~1; + count = min(unsigned long, userCount, frameLeft) & ~1; used = count; if (copy_from_user(p, userPtr, count)) return -EFAULT; } else { u_char *left = &frame[*frameUsed>>1]; u_char *right = left+write_sq_block_size_half; - count = min(userCount, frameLeft)>>1 & ~1; + count = min(unsigned long, userCount, frameLeft)>>1 & ~1; used = count*2; while (count > 0) { if (get_user(*left++, userPtr++) @@ -189,7 +189,7 @@ static ssize_t funcname(const u_char *userPtr, size_t userCount, \ \ if (!dmasound.soft.stereo) { \ u_char *p = &frame[*frameUsed]; \ - count = min(userCount, frameLeft) & ~1; \ + count = min(unsigned long, userCount, frameLeft) & ~1; \ used = count; \ while (count > 0) { \ u_char data; \ @@ -201,7 +201,7 @@ 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(userCount, frameLeft)>>1 & ~1; \ + count = min(unsigned long, userCount, frameLeft)>>1 & ~1;\ used = count*2; \ while (count > 0) { \ u_char data; \ @@ -242,7 +242,7 @@ 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(userCount, frameLeft)>>1 & ~1; \ + count = min(unsigned long, userCount, frameLeft)>>1 & ~1;\ used = count*2; \ while (count > 0) { \ if (get_user(data, ((u_short *)userPtr)++)) \ @@ -257,7 +257,7 @@ 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(userCount, frameLeft)>>2 & ~1; \ + count = min(unsigned long, userCount, frameLeft)>>2 & ~1;\ used = count*4; \ while (count > 0) { \ if (get_user(data, ((u_short *)userPtr)++)) \ diff --git a/drivers/sound/dmasound/dmasound_q40.c b/drivers/sound/dmasound/dmasound_q40.c index db6960c147da..542935113ecf 100644 --- a/drivers/sound/dmasound/dmasound_q40.c +++ b/drivers/sound/dmasound/dmasound_q40.c @@ -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(userCount, frameLeft); + used = count = min(unsigned long, userCount, frameLeft); if (copy_from_user(p,userPtr,count)) return -EFAULT; while (count > 0) { @@ -84,7 +84,7 @@ static ssize_t q40_ct_law(const u_char *userPtr, size_t userCount, frameLeft >>= 1; if (stereo) userCount >>= 1; - used = count = min(userCount, frameLeft); + used = count = min(unsigned long, userCount, frameLeft); while (count > 0) { u_char data; if (get_user(data, userPtr++)) @@ -112,7 +112,7 @@ 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(userCount, frameLeft); + used = count = min(unsigned long, userCount, frameLeft); if (copy_from_user(p,userPtr,count)) return -EFAULT; while (count > 0) { @@ -136,7 +136,7 @@ static ssize_t q40_ct_s8(const u_char *userPtr, size_t userCount, frameLeft >>= 1; if (stereo) userCount >>= 1; - used = count = min(userCount, frameLeft); + used = count = min(unsigned long, userCount, frameLeft); while (count > 0) { u_char data; if (get_user(data, userPtr++)) @@ -164,7 +164,7 @@ 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(userCount, frameLeft); + used = count = min(unsigned long, 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(userCount, frameLeft); + used = count = min(unsigned long, userCount, frameLeft); while (count > 0) { u_char data; if (get_user(data, userPtr++)) diff --git a/drivers/sound/emu10k1/audio.c b/drivers/sound/emu10k1/audio.c index 15b5e3fb5de0..dd49c2f4a128 100644 --- a/drivers/sound/emu10k1/audio.c +++ b/drivers/sound/emu10k1/audio.c @@ -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(bytestocopy, count); + bytestocopy = min(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(bytestocopy, count); + bytestocopy = min(u32, bytestocopy, count); emu10k1_waveout_xferdata(woinst, (u8 *) buffer, &bytestocopy); diff --git a/drivers/sound/emu10k1/cardwi.c b/drivers/sound/emu10k1/cardwi.c index 03c459512bd6..184dcd5a8c8d 100644 --- a/drivers/sound/emu10k1/cardwi.c +++ b/drivers/sound/emu10k1/cardwi.c @@ -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(buffer->size, *size); + sizetocopy = min(u32, buffer->size, *size); *size = sizetocopy; if (!sizetocopy) diff --git a/drivers/sound/emu10k1/cardwo.c b/drivers/sound/emu10k1/cardwo.c index 0d72f4d6348f..c01919627663 100644 --- a/drivers/sound/emu10k1/cardwo.c +++ b/drivers/sound/emu10k1/cardwo.c @@ -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(buffer->size, *size); + sizetocopy = min(u32, buffer->size, *size); *size = sizetocopy; if (!sizetocopy) diff --git a/drivers/sound/emu10k1/hwaccess.h b/drivers/sound/emu10k1/hwaccess.h index 300ca5e4fbd5..bde2e866bc70 100644 --- a/drivers/sound/emu10k1/hwaccess.h +++ b/drivers/sound/emu10k1/hwaccess.h @@ -53,8 +53,6 @@ #define FLAGS_AVAILABLE 0x0001 #define FLAGS_READY 0x0002 -#define min(x,y) ((x) < (y)) ? (x) : (y) - struct memhandle { dma_addr_t dma_handle; diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c index 18e82fdf9ca7..1089b9408817 100644 --- a/drivers/telephony/ixj.c +++ b/drivers/telephony/ixj.c @@ -1844,14 +1844,15 @@ ssize_t ixj_read(struct file * file_p, char *buf, size_t length, loff_t * ppos) remove_wait_queue(&j->read_q, &wait); set_current_state(TASK_RUNNING); /* Don't ever copy more than the user asks */ - i = copy_to_user(buf, j->read_buffer, min(length, j->read_buffer_size)); + i = copy_to_user(buf, j->read_buffer, + min(unsigned int, length, j->read_buffer_size)); j->read_buffer_ready = 0; if (i) { j->flags.inread = 0; return -EFAULT; } else { j->flags.inread = 0; - return min(length, j->read_buffer_size); + return min(unsigned int, length, j->read_buffer_size); } } @@ -1934,13 +1935,14 @@ ssize_t ixj_write(struct file *file_p, const char *buf, size_t count, loff_t * p remove_wait_queue(&j->write_q, &wait); if (j->write_buffer_wp + count >= j->write_buffer_end) j->write_buffer_wp = j->write_buffer; - i = copy_from_user(j->write_buffer_wp, buf, min(count, j->write_buffer_size)); + i = copy_from_user(j->write_buffer_wp, buf, + min(unsigned int, count, j->write_buffer_size)); if (i) { j->flags.inwrite = 0; return -EFAULT; } j->flags.inwrite = 0; - return min(count, j->write_buffer_size); + return min(unsigned int, count, j->write_buffer_size); } ssize_t ixj_enhanced_write(struct file * file_p, const char *buf, size_t count, loff_t * ppos) diff --git a/drivers/telephony/ixj.h b/drivers/telephony/ixj.h index 560c10271f5d..43cc9fe436e1 100644 --- a/drivers/telephony/ixj.h +++ b/drivers/telephony/ixj.h @@ -54,13 +54,6 @@ typedef __u8 BOOL; #define TRUE 1 #define FALSE 0 -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef max -#define max(a,b) (((a)>(b))?(a):(b)) -#endif - /****************************************************************************** * * This structure when unioned with the structures below makes simple byte diff --git a/drivers/usb/devio.c b/drivers/usb/devio.c index 7f0c0df732c5..714449eb437d 100644 --- a/drivers/usb/devio.c +++ b/drivers/usb/devio.c @@ -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 (size, retval)? */ + /* size = min(int, size, retval)? */ } /* cleanup and return */ diff --git a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h index 9a0f75198c30..3cfac6cf6838 100644 --- a/drivers/usb/serial/io_usbvend.h +++ b/drivers/usb/serial/io_usbvend.h @@ -115,7 +115,7 @@ // TxCredits value below which driver won't bother sending (to prevent too many small writes). // Send only if above 25% -#define EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(InitialCredit) (max( ((InitialCredit) / 4), EDGE_FW_BULK_MAX_PACKET_SIZE )) +#define EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(InitialCredit) (max(int, ((InitialCredit) / 4), EDGE_FW_BULK_MAX_PACKET_SIZE)) #define EDGE_FW_BULK_MAX_PACKET_SIZE 64 // Max Packet Size for Bulk In Endpoint (EP1) #define EDGE_FW_BULK_READ_BUFFER_SIZE 1024 // Size to use for Bulk reads diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index 57b18b765a55..c98b8caac680 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c @@ -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(totallen, 65536); + len = min(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(totallen, 65536); + len = min(int, totallen, 65536); if (use_sg) { sg = (struct scatterlist *) src; diff --git a/drivers/usb/storage/datafab.h b/drivers/usb/storage/datafab.h index 7453d8b39aa3..5515583ddce3 100644 --- a/drivers/usb/storage/datafab.h +++ b/drivers/usb/storage/datafab.h @@ -24,8 +24,6 @@ #ifndef _USB_DATAFAB_MDCFE_B_H #define _USB_DATAFAB_MDCFE_B_H -#define min(a,b) (((a)<(b))?(a):(b)) // this is defined in tons of header files, i wish it had a standard single definition... - extern int datafab_transport(Scsi_Cmnd *srb, struct us_data *us); struct datafab_info { diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index 0730eac4ca4f..9462a601572a 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c @@ -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(totallen, 65536); + len = min(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(totallen, 65536); + len = min(int, totallen, 65536); if (use_sg) { sg = (struct scatterlist *) src; diff --git a/drivers/usb/storage/jumpshot.h b/drivers/usb/storage/jumpshot.h index 6d28cb204f1f..8147197cd4fc 100644 --- a/drivers/usb/storage/jumpshot.h +++ b/drivers/usb/storage/jumpshot.h @@ -24,8 +24,6 @@ #ifndef _USB_JUMPSHOT_H #define _USB_JUMPSHOT_H -#define min(a,b) (((a)<(b))?(a):(b)) // this is defined in tons of header files, i wish it had a standar single definition... - extern int jumpshot_transport(Scsi_Cmnd *srb, struct us_data *us); struct jumpshot_info { diff --git a/drivers/usb/uhci.c b/drivers/usb/uhci.c index 1edd3b1ae1ea..dbba809ff82e 100644 --- a/drivers/usb/uhci.c +++ b/drivers/usb/uhci.c @@ -98,8 +98,6 @@ static int ports_active(struct uhci *uhci); static void suspend_hc(struct uhci *uhci); static void wakeup_hc(struct uhci *uhci); -#define min(a,b) (((a)<(b))?(a):(b)) - /* If a transfer is still active after this much time, turn off FSBR */ #define IDLE_TIMEOUT (HZ / 20) /* 50 ms */ @@ -2133,11 +2131,15 @@ static int rh_submit_urb(struct urb *urb) case RH_GET_DESCRIPTOR: switch ((wValue & 0xff00) >> 8) { case 0x01: /* device descriptor */ - len = min(leni, min(sizeof(root_hub_dev_des), wLength)); + len = min(unsigned int, leni, + min(unsigned int, + sizeof(root_hub_dev_des), wLength)); memcpy(data, root_hub_dev_des, len); OK(len); case 0x02: /* configuration descriptor */ - len = min(leni, min(sizeof(root_hub_config_des), wLength)); + len = min(unsigned int, leni, + min(unsigned int, + sizeof(root_hub_config_des), wLength)); memcpy (data, root_hub_config_des, len); OK(len); case 0x03: /* string descriptors */ @@ -2145,14 +2147,15 @@ static int rh_submit_urb(struct urb *urb) uhci->io_addr, "UHCI-alt", data, wLength); if (len > 0) { - OK (min (leni, len)); + OK(min(int, leni, len)); } else stat = -EPIPE; } break; case RH_GET_DESCRIPTOR | RH_CLASS: root_hub_hub_des[2] = uhci->rh.numports; - len = min(leni, min(sizeof(root_hub_hub_des), wLength)); + len = min(unsigned int, leni, + min(unsigned int, sizeof(root_hub_hub_des), wLength)); memcpy(data, root_hub_hub_des, len); OK(len); case RH_GET_CONFIGURATION: diff --git a/drivers/usb/usb-ohci.c b/drivers/usb/usb-ohci.c index 5e264d766fca..dd1c2d0d2f31 100644 --- a/drivers/usb/usb-ohci.c +++ b/drivers/usb/usb-ohci.c @@ -1805,7 +1805,9 @@ static int rh_send_irq (ohci_t * ohci, void * rh_data, int rh_len) len = i/8 + 1; if (ret > 0) { - memcpy (rh_data, data, min (len, min (rh_len, sizeof(data)))); + memcpy(rh_data, data, + min(unsigned int, len, + min(unsigned int, rh_len, sizeof(data)))); return len; } return 0; @@ -1987,10 +1989,18 @@ static int rh_submit_urb (urb_t * urb) case RH_GET_DESCRIPTOR: switch ((wValue & 0xff00) >> 8) { case (0x01): /* device descriptor */ - len = min (leni, min (sizeof (root_hub_dev_des), wLength)); + len = min(unsigned int, + leni, + min(unsigned int, + sizeof (root_hub_dev_des), + wLength)); data_buf = root_hub_dev_des; OK(len); case (0x02): /* configuration descriptor */ - len = min (leni, min (sizeof (root_hub_config_des), wLength)); + len = min(unsigned int, + leni, + min(unsigned int, + sizeof (root_hub_config_des), + wLength)); data_buf = root_hub_config_des; OK(len); case (0x03): /* string descriptors */ len = usb_root_hub_string (wValue & 0xff, @@ -1998,7 +2008,7 @@ static int rh_submit_urb (urb_t * urb) data, wLength); if (len > 0) { data_buf = data; - OK (min (leni, len)); + OK(min(int, leni, len)); } // else fallthrough default: @@ -2033,7 +2043,8 @@ static int rh_submit_urb (urb_t * urb) data_buf [10] = data_buf [9] = 0xff; } - len = min (leni, min (data_buf [0], wLength)); + len = min(unsigned int, leni, + min(unsigned int, data_buf [0], wLength)); OK (len); } @@ -2050,7 +2061,7 @@ static int rh_submit_urb (urb_t * urb) // ohci_dump_roothub (ohci, 0); #endif - len = min(len, leni); + len = min(int, len, leni); if (data != data_buf) memcpy (data, data_buf, len); urb->actual_length = len; diff --git a/drivers/usb/usb-ohci.h b/drivers/usb/usb-ohci.h index 75288d333f7e..0ad3813ae32e 100644 --- a/drivers/usb/usb-ohci.h +++ b/drivers/usb/usb-ohci.h @@ -329,9 +329,6 @@ struct virt_root_hub { #define RH_A_NOCP (1 << 12) /* no over current protection */ #define RH_A_POTPGT (0xff << 24) /* power on to power good time */ -#define min(a,b) (((a)<(b))?(a):(b)) - - /* urb */ typedef struct { diff --git a/drivers/usb/usb-uhci.c b/drivers/usb/usb-uhci.c index 4aa3080d39c2..4b23cfe1adcc 100644 --- a/drivers/usb/usb-uhci.c +++ b/drivers/usb/usb-uhci.c @@ -2159,11 +2159,15 @@ _static int rh_submit_urb (urb_t *urb) case RH_GET_DESCRIPTOR: switch ((wValue & 0xff00) >> 8) { case (0x01): /* device descriptor */ - len = min (leni, min (sizeof (root_hub_dev_des), wLength)); + len = min(unsigned int, leni, + min(unsigned int, + sizeof (root_hub_dev_des), wLength)); memcpy (data, root_hub_dev_des, len); OK (len); case (0x02): /* configuration descriptor */ - len = min (leni, min (sizeof (root_hub_config_des), wLength)); + len = min(unsigned int, leni, + min(unsigned int, + sizeof (root_hub_config_des), wLength)); memcpy (data, root_hub_config_des, len); OK (len); case (0x03): /* string descriptors */ @@ -2171,7 +2175,7 @@ _static int rh_submit_urb (urb_t *urb) uhci->io_addr, "UHCI", data, wLength); if (len > 0) { - OK (min (leni, len)); + OK(min(int, leni, len)); } else stat = -EPIPE; } @@ -2179,7 +2183,8 @@ _static int rh_submit_urb (urb_t *urb) case RH_GET_DESCRIPTOR | RH_CLASS: root_hub_hub_des[2] = uhci->rh.numports; - len = min (leni, min (sizeof (root_hub_hub_des), wLength)); + len = min(unsigned int, leni, + min(unsigned int, sizeof (root_hub_hub_des), wLength)); memcpy (data, root_hub_hub_des, len); OK (len); diff --git a/drivers/usb/usb-uhci.h b/drivers/usb/usb-uhci.h index 84b47949c769..7ab3757bb8ae 100644 --- a/drivers/usb/usb-uhci.h +++ b/drivers/usb/usb-uhci.h @@ -282,6 +282,4 @@ typedef struct uhci { #define RH_REQ_ERR -1 #define RH_NACK 0x00 -#define min(a,b) (((a)<(b))?(a):(b)) - #endif diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c index 38633668ebd7..825959e18998 100644 --- a/drivers/video/amifb.c +++ b/drivers/video/amifb.c @@ -592,9 +592,6 @@ static u_short maxfmode, chipset; ((((long)((unsigned long long)x1 >> 8) % x2) << 8) / x2)) #endif -#define min(a, b) ((a) < (b) ? (a) : (b)) -#define max(a, b) ((a) > (b) ? (a) : (b)) - #define highw(x) ((u_long)(x)>>16 & 0xffff) #define loww(x) ((u_long)(x) & 0xffff) diff --git a/drivers/video/cyberfb.h b/drivers/video/cyberfb.h index 2acff941a099..8435c430ad27 100644 --- a/drivers/video/cyberfb.h +++ b/drivers/video/cyberfb.h @@ -100,14 +100,6 @@ /**************************************************/ -#ifndef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#endif /* !min */ - -#ifndef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#endif /* !max */ - /* support for a BitBlt operation. The op-codes are identical to X11 GCs */ #define GRFBBOPclear 0x0 /* 0 */ diff --git a/fs/buffer.c b/fs/buffer.c index 55c416e8a63c..3a5b99524225 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -794,6 +794,17 @@ void set_blocksize(kdev_t dev, int size) goto retry; } +static void free_more_memory(void) +{ + balance_dirty(NODEV); + page_launder(GFP_NOFS, 0); + wakeup_bdflush(); + wakeup_kswapd(); + current->policy |= SCHED_YIELD; + __set_current_state(TASK_RUNNING); + schedule(); +} + /* * We used to try various strange things. Let's not. * We'll just try to balance dirty buffers, and possibly @@ -802,15 +813,8 @@ void set_blocksize(kdev_t dev, int size) */ static void refill_freelist(int size) { - if (!grow_buffers(size)) { - balance_dirty(NODEV); - page_launder(GFP_NOFS, 0); - wakeup_bdflush(); - wakeup_kswapd(); - current->policy |= SCHED_YIELD; - __set_current_state(TASK_RUNNING); - schedule(); - } + if (!grow_buffers(size)) + free_more_memory(); } void init_buffer(struct buffer_head *bh, bh_end_io_t *handler, void *private) @@ -1408,9 +1412,7 @@ no_grow: */ run_task_queue(&tq_disk); - current->policy |= SCHED_YIELD; - __set_current_state(TASK_RUNNING); - schedule(); + free_more_memory(); goto try_again; } diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index 7c8afc26dc92..dac80dc811cd 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c @@ -69,17 +69,9 @@ do {\ outsize = insize; \ } while (0) -static inline int max(int a, int b) -{ - if ( a > b ) - return a; - else - return b; -} - #define INSIZE(tag) sizeof(struct coda_ ## tag ## _in) #define OUTSIZE(tag) sizeof(struct coda_ ## tag ## _out) -#define SIZE(tag) max(INSIZE(tag), OUTSIZE(tag)) +#define SIZE(tag) max(unsigned int, INSIZE(tag), OUTSIZE(tag)) /* the upcalls */ @@ -159,7 +151,7 @@ int venus_lookup(struct super_block *sb, struct ViceFid *fid, int offset; offset = INSIZE(lookup); - insize = max(offset + length +1, OUTSIZE(lookup)); + insize = max(unsigned int, offset + length +1, OUTSIZE(lookup)); UPARG(CODA_LOOKUP); inp->coda_lookup.VFid = *fid; @@ -275,7 +267,7 @@ int venus_mkdir(struct super_block *sb, struct ViceFid *dirfid, int offset; offset = INSIZE(mkdir); - insize = max(offset + length + 1, OUTSIZE(mkdir)); + insize = max(unsigned int, offset + length + 1, OUTSIZE(mkdir)); UPARG(CODA_MKDIR); inp->coda_mkdir.VFid = *dirfid; @@ -306,7 +298,7 @@ int venus_rename(struct super_block *sb, struct ViceFid *old_fid, int offset, s; offset = INSIZE(rename); - insize = max(offset + new_length + old_length + 8, + insize = max(unsigned int, offset + new_length + old_length + 8, OUTSIZE(rename)); UPARG(CODA_RENAME); @@ -344,7 +336,7 @@ int venus_create(struct super_block *sb, struct ViceFid *dirfid, int offset; offset = INSIZE(create); - insize = max(offset + length + 1, OUTSIZE(create)); + insize = max(unsigned int, offset + length + 1, OUTSIZE(create)); UPARG(CODA_CREATE); inp->coda_create.VFid = *dirfid; @@ -376,7 +368,7 @@ int venus_rmdir(struct super_block *sb, struct ViceFid *dirfid, int offset; offset = INSIZE(rmdir); - insize = max(offset + length + 1, OUTSIZE(rmdir)); + insize = max(unsigned int, offset + length + 1, OUTSIZE(rmdir)); UPARG(CODA_RMDIR); inp->coda_rmdir.VFid = *dirfid; @@ -398,7 +390,7 @@ int venus_remove(struct super_block *sb, struct ViceFid *dirfid, int error=0, insize, outsize, offset; offset = INSIZE(remove); - insize = max(offset + length + 1, OUTSIZE(remove)); + insize = max(unsigned int, offset + length + 1, OUTSIZE(remove)); UPARG(CODA_REMOVE); inp->coda_remove.VFid = *dirfid; @@ -421,7 +413,8 @@ int venus_readlink(struct super_block *sb, struct ViceFid *fid, int retlen; char *result; - insize = max(INSIZE(readlink), OUTSIZE(readlink)+ *length + 1); + insize = max(unsigned int, + INSIZE(readlink), OUTSIZE(readlink)+ *length + 1); UPARG(CODA_READLINK); inp->coda_readlink.VFid = *fid; @@ -455,7 +448,7 @@ int venus_link(struct super_block *sb, struct ViceFid *fid, int offset; offset = INSIZE(link); - insize = max(offset + len + 1, OUTSIZE(link)); + insize = max(unsigned int, offset + len + 1, OUTSIZE(link)); UPARG(CODA_LINK); inp->coda_link.sourceFid = *fid; @@ -484,7 +477,7 @@ int venus_symlink(struct super_block *sb, struct ViceFid *fid, int offset, s; offset = INSIZE(symlink); - insize = max(offset + len + symlen + 8, OUTSIZE(symlink)); + insize = max(unsigned int, offset + len + symlen + 8, OUTSIZE(symlink)); UPARG(CODA_SYMLINK); /* inp->coda_symlink.attr = *tva; XXXXXX */ @@ -624,7 +617,7 @@ int venus_statfs(struct super_block *sb, struct statfs *sfs) union outputArgs *outp; int insize, outsize, error; - insize = max(INSIZE(statfs), OUTSIZE(statfs)); + insize = max(unsigned int, INSIZE(statfs), OUTSIZE(statfs)); UPARG(CODA_STATFS); error = coda_upcall(coda_sbp(sb), insize, &outsize, inp); diff --git a/fs/fat/cache.c b/fs/fat/cache.c index 7240bc8a2e52..f5fea6704d6f 100644 --- a/fs/fat/cache.c +++ b/fs/fat/cache.c @@ -15,6 +15,8 @@ #include <linux/stat.h> #include <linux/fat_cvf.h> +#include "msbuffer.h" + #if 0 # define PRINTK(x) printk x #else diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 7e83e79f777b..0b047c3bbe05 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c @@ -590,7 +590,7 @@ static int vfat_ioctl_fill( void * buf, const char * name, int name_len, - off_t offset, + loff_t offset, ino_t ino, unsigned int d_type) { diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c index 7ea3d4a10168..a480ab70b880 100644 --- a/fs/jffs/inode-v23.c +++ b/fs/jffs/inode-v23.c @@ -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 = jffs_min(inode->i_size - offset, PAGE_SIZE); + read_len = min(long, inode->i_size - offset, PAGE_SIZE); r = jffs_read_data(f, buf, offset, read_len); if (r == read_len) { if (read_len < PAGE_SIZE) { @@ -1373,7 +1373,9 @@ jffs_file_write(struct file *filp, const char *buf, size_t count, goto out_isem; } - thiscount = jffs_min(c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode), count); + thiscount = min(unsigned int, + c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode), + count); if (!(vbuf = kmalloc(thiscount, GFP_KERNEL))) { D(printk("jffs_file_write(): failed to allocate bounce buffer. Fix me to use page cache\n")); @@ -1437,7 +1439,8 @@ jffs_file_write(struct file *filp, const char *buf, size_t count, raw_inode.deleted = 0; if (pos < f->size) { - node->removed_size = raw_inode.rsize = jffs_min(thiscount, f->size - pos); + node->removed_size = raw_inode.rsize = + min(unsigned int, thiscount, f->size - pos); /* If this node is going entirely over the top of old data, we can allow it to go into the reserved space, because @@ -1479,7 +1482,9 @@ 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 = jffs_min(c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode), count); + thiscount = min(unsigned int, + c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode), + count); } out: D3(printk (KERN_NOTICE "file_write(): up biglock\n")); diff --git a/fs/jffs/intrep.c b/fs/jffs/intrep.c index 62af52c92a8b..d8d3c9007795 100644 --- a/fs/jffs/intrep.c +++ b/fs/jffs/intrep.c @@ -292,21 +292,6 @@ flash_erase_region(struct mtd_info *mtd, loff_t start, return 0; } - -inline int -jffs_min(int a, int b) -{ - return (a < b ? a : b); -} - - -inline int -jffs_max(int a, int b) -{ - return (a > b ? a : b); -} - - /* This routine calculates checksums in JFFS. */ __u32 jffs_checksum(const void *data, int size) @@ -1624,7 +1609,7 @@ 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 = jffs_min(avail, max_size); + r = min(u32, avail, max_size); D3(printk(KERN_NOTICE "jffs_get_node_data\n")); flash_safe_read(fmc->mtd, pos, buf, r); @@ -1677,8 +1662,8 @@ 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 = jffs_min(size - read_data, - node->data_size - node_offset); + r = min(u32, size - read_data, + node->data_size - node_offset); memset(&buf[read_data], 0, r); } else if ((r = jffs_get_node_data(f, node, &buf[read_data], @@ -1919,8 +1904,8 @@ 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 = jffs_min(n->data_offset + n->data_size - - offset, remove_size); + int r = min(u32, n->data_offset + n->data_size + - offset, remove_size); n->data_size -= r; remove_size -= r; n = n->range_next; @@ -2475,7 +2460,7 @@ jffs_rewrite_data(struct jffs_file *f, struct jffs_node *node, int size) } while (size) { - __u32 s = jffs_min(size, PAGE_SIZE); + __u32 s = min(int, size, PAGE_SIZE); if ((r = jffs_read_data(f, (char *)page, offset, s)) < s) { free_page((unsigned long)page); @@ -2836,7 +2821,7 @@ jffs_try_to_erase(struct jffs_control *c) printk("JFFS: Erase failed! pos = 0x%lx\n", (long)pos); jffs_hexdump(fmc->mtd, pos, - jffs_min(256, end - pos)); + min(u32, 256, end - pos)); err = -1; break; } diff --git a/fs/jffs/intrep.h b/fs/jffs/intrep.h index f10a994b4e06..64930d867efe 100644 --- a/fs/jffs/intrep.h +++ b/fs/jffs/intrep.h @@ -17,8 +17,6 @@ #ifndef __LINUX_JFFS_INTREP_H__ #define __LINUX_JFFS_INTREP_H__ #include "jffs_fm.h" -inline int jffs_min(int a, int b); -inline int jffs_max(int a, int b); __u32 jffs_checksum(const void *data, int size); void jffs_cleanup_control(struct jffs_control *c); diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c index dd54dea04152..a72ed803d014 100644 --- a/fs/ncpfs/file.c +++ b/fs/ncpfs/file.c @@ -22,11 +22,6 @@ #include <linux/ncp_fs.h> #include "ncplib_kernel.h" -static inline unsigned int min(unsigned int a, unsigned int b) -{ - return a < b ? a : b; -} - static int ncp_fsync(struct file *file, struct dentry *dentry, int datasync) { return 0; @@ -157,8 +152,9 @@ 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(bufsize - (pos % bufsize), - count - already_read); + size_t to_read = min(unsigned int, + bufsize - (pos % bufsize), + count - already_read); error = ncp_read_bounce(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle, @@ -238,8 +234,9 @@ 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(bufsize - (pos % bufsize), - count - already_written); + size_t to_write = min(unsigned int, + bufsize - (pos % bufsize), + count - already_written); if (copy_from_user(bouncebuffer, buf, to_write)) { errno = -EFAULT; diff --git a/fs/ncpfs/mmap.c b/fs/ncpfs/mmap.c index ed4153dd61ca..ad74d57b8d0b 100644 --- a/fs/ncpfs/mmap.c +++ b/fs/ncpfs/mmap.c @@ -22,11 +22,6 @@ #include <asm/uaccess.h> #include <asm/system.h> -static inline int min(int a, int b) -{ - return a < b ? a : b; -} - /* * Fill in the supplied page for mmap */ @@ -66,7 +61,7 @@ static struct page* ncp_file_mmap_nopage(struct vm_area_struct *area, to_read = bufsize - (pos % bufsize); - to_read = min(to_read, count - already_read); + to_read = min(unsigned int, to_read, count - already_read); if (ncp_read_kernel(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle, diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c index 6e09c8bf2613..3a0fd85d8f73 100644 --- a/fs/ncpfs/ncplib_kernel.c +++ b/fs/ncpfs/ncplib_kernel.c @@ -13,11 +13,6 @@ #include "ncplib_kernel.h" -static inline int min(int a, int b) -{ - return a < b ? a : b; -} - static inline void assert_server_locked(struct ncp_server *server) { if (server->lock == 0) { @@ -132,7 +127,7 @@ ncp_negotiate_buffersize(struct ncp_server *server, int size, int *target) ncp_unlock_server(server); return result; } - *target = min(ntohs(ncp_reply_word(server, 0)), size); + *target = min(unsigned int, ntohs(ncp_reply_word(server, 0)), size); ncp_unlock_server(server); return 0; @@ -163,7 +158,8 @@ ncp_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(result, size); + if (result >= NCP_BLOCK_SIZE) + size = min(int, result, size); *ret_size = size; *ret_options = ncp_reply_byte(server, 4); diff --git a/fs/ncpfs/ncpsign_kernel.c b/fs/ncpfs/ncpsign_kernel.c index f945da65798a..ea8482611fcd 100644 --- a/fs/ncpfs/ncpsign_kernel.c +++ b/fs/ncpfs/ncpsign_kernel.c @@ -52,8 +52,6 @@ DSET_LH(__u8 * buf, int pos, __u32 val) #define PUT_LE32(p,v) DSET_LH(p,0,v) #endif -#define min(a,b) ((a)<(b)?(a):(b)) - static void nwsign(char *r_data1, char *r_data2, char *outdata) { int i; unsigned int w0,w1,w2,w3; @@ -102,7 +100,7 @@ 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((*size)-sizeof(struct ncp_request_header)+1,52)); + min(unsigned int,(*size)-sizeof(struct ncp_request_header)+1,52)); nwsign(server->sign_last,data,server->sign_last); diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 66d102bae6de..92ed9fb5ebc6 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -39,7 +39,6 @@ static ssize_t nfs_file_read(struct file *, char *, size_t, loff_t *); static ssize_t nfs_file_write(struct file *, const char *, size_t, loff_t *); static int nfs_file_flush(struct file *); static int nfs_fsync(struct file *, struct dentry *dentry, int datasync); -static int nfs_file_release(struct inode *, struct file *); struct file_operations nfs_file_operations = { llseek: generic_file_llseek, @@ -48,7 +47,7 @@ struct file_operations nfs_file_operations = { mmap: nfs_file_mmap, open: nfs_open, flush: nfs_file_flush, - release: nfs_file_release, + release: nfs_release, fsync: nfs_fsync, lock: nfs_lock, }; @@ -89,13 +88,6 @@ nfs_file_flush(struct file *file) return status; } -static int -nfs_file_release(struct inode *inode, struct file *file) -{ - filemap_fdatasync(inode->i_mapping); - return nfs_release(inode,file); -} - static ssize_t nfs_file_read(struct file * file, char * buf, size_t count, loff_t *ppos) { diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 2d79aefe1940..c48ebbc15c81 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -48,6 +48,7 @@ static void nfs_read_inode(struct inode *); static void nfs_write_inode(struct inode *,int); static void nfs_delete_inode(struct inode *); static void nfs_put_super(struct super_block *); +static void nfs_clear_inode(struct inode *); static void nfs_umount_begin(struct super_block *); static int nfs_statfs(struct super_block *, struct statfs *); @@ -57,6 +58,7 @@ static struct super_operations nfs_sops = { delete_inode: nfs_delete_inode, put_super: nfs_put_super, statfs: nfs_statfs, + clear_inode: nfs_clear_inode, umount_begin: nfs_umount_begin, }; @@ -141,6 +143,19 @@ nfs_delete_inode(struct inode * inode) clear_inode(inode); } +/* + * For the moment, the only task for the NFS clear_inode method is to + * release the mmap credential + */ +static void +nfs_clear_inode(struct inode *inode) +{ + struct rpc_cred *cred = NFS_I(inode)->mm_cred; + + if (cred) + put_rpccred(cred); +} + void nfs_put_super(struct super_block *sb) { @@ -600,7 +615,6 @@ nfs_fill_inode(struct inode *inode, struct nfs_fh *fh, struct nfs_fattr *fattr) inode->i_ctime = nfs_time_to_secs(fattr->ctime); NFS_CACHE_CTIME(inode) = fattr->ctime; NFS_CACHE_MTIME(inode) = fattr->mtime; - NFS_CACHE_ATIME(inode) = fattr->atime; NFS_CACHE_ISIZE(inode) = fattr->size; NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); NFS_ATTRTIMEO_UPDATE(inode) = jiffies; @@ -794,6 +808,21 @@ nfs_revalidate(struct dentry *dentry) } /* + * Ensure that mmap has a recent RPC credential for use when writing out + * shared pages + */ +static inline void +nfs_set_mmcred(struct inode *inode, struct rpc_cred *cred) +{ + struct rpc_cred **p = &NFS_I(inode)->mm_cred, + *oldcred = *p; + + *p = get_rpccred(cred); + if (oldcred) + put_rpccred(oldcred); +} + +/* * These are probably going to contain hooks for * allocating and releasing RPC credentials for * the file. I'll have to think about Tronds patch @@ -808,20 +837,20 @@ int nfs_open(struct inode *inode, struct file *filp) auth = NFS_CLIENT(inode)->cl_auth; cred = rpcauth_lookupcred(auth, 0); filp->private_data = cred; + if (filp->f_mode & FMODE_WRITE) + nfs_set_mmcred(inode, cred); unlock_kernel(); return 0; } int nfs_release(struct inode *inode, struct file *filp) { - struct rpc_auth *auth; struct rpc_cred *cred; lock_kernel(); - auth = NFS_CLIENT(inode)->cl_auth; cred = nfs_file_cred(filp); if (cred) - rpcauth_releasecred(auth, cred); + put_rpccred(cred); unlock_kernel(); return 0; } @@ -976,7 +1005,6 @@ __nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) NFS_CACHE_CTIME(inode) = fattr->ctime; inode->i_ctime = nfs_time_to_secs(fattr->ctime); - NFS_CACHE_ATIME(inode) = fattr->atime; inode->i_atime = nfs_time_to_secs(fattr->atime); NFS_CACHE_MTIME(inode) = new_mtime; diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 51150971478c..800fc5767459 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c @@ -128,7 +128,7 @@ nfs_async_unlink_done(struct rpc_task *task) dir_i = dir->d_inode; nfs_zap_caches(dir_i); NFS_PROTO(dir_i)->unlink_done(dir, &task->tk_msg); - rpcauth_releasecred(task->tk_auth, data->cred); + put_rpccred(data->cred); data->cred = NULL; dput(dir); } diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 3055940692ad..42f5f90677d9 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -181,7 +181,9 @@ nfs_writepage_sync(struct file *file, struct inode *inode, struct page *page, if (file) - cred = nfs_file_cred(file); + cred = get_rpccred(nfs_file_cred(file)); + if (!cred) + cred = get_rpccred(NFS_I(inode)->mm_cred); dprintk("NFS: nfs_writepage_sync(%x/%Ld %d@%Ld)\n", inode->i_dev, (long long)NFS_FILEID(inode), @@ -226,6 +228,8 @@ nfs_writepage_sync(struct file *file, struct inode *inode, struct page *page, io_error: kunmap(page); + if (cred) + put_rpccred(cred); return written? written : result; } @@ -241,6 +245,9 @@ nfs_writepage_async(struct file *file, struct inode *inode, struct page *page, status = (IS_ERR(req)) ? PTR_ERR(req) : 0; if (status < 0) goto out; + if (!req->wb_cred) + req->wb_cred = get_rpccred(NFS_I(inode)->mm_cred); + nfs_unlock_request(req); nfs_release_request(req); nfs_strategy(inode); out: @@ -557,13 +564,11 @@ struct nfs_page *nfs_create_request(struct file *file, struct inode *inode, req->wb_bytes = count; req->wb_file = file; - /* If we have a struct file, use its cached credentials - * else cache the current process' credentials. */ + /* If we have a struct file, use its cached credentials */ if (file) { get_file(file); req->wb_cred = nfs_file_cred(file); - } else - req->wb_cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0); + } req->wb_inode = inode; req->wb_count = 1; @@ -608,8 +613,8 @@ nfs_release_request(struct nfs_page *req) /* Release struct file or cached credential */ if (req->wb_file) fput(req->wb_file); - else - rpcauth_releasecred(NFS_CLIENT(inode)->cl_auth, req->wb_cred); + else if (req->wb_cred) + put_rpccred(req->wb_cred); page_cache_release(page); nfs_page_free(req); /* wake up anyone waiting to allocate a request */ @@ -927,8 +932,6 @@ nfs_update_request(struct file* file, struct inode *inode, struct page *page, if (end > rqend) req->wb_bytes = end - req->wb_offset; - nfs_unlock_request(req); - return req; } @@ -1049,6 +1052,7 @@ nfs_updatepage(struct file *file, struct page *page, unsigned int offset, unsign goto done; status = 0; + nfs_unlock_request(req); /* If we wrote past the end of the page. * Call the strategy routine so it can send out a bunch * of requests. diff --git a/fs/ntfs/attr.c b/fs/ntfs/attr.c index 57be1396297f..80706fdf0d0e 100644 --- a/fs/ntfs/attr.c +++ b/fs/ntfs/attr.c @@ -148,7 +148,7 @@ int ntfs_new_attr(ntfs_inode *ino, int type, void *name, int namelen, "attribute non-resident. Bug!\n"); return -EINVAL; } - m = memcmp(value, a->d.data, min(value_len, a->size)); + m = memcmp(value, a->d.data, min(int, value_len, a->size)); if (m > 0) continue; if (m < 0) { @@ -379,7 +379,7 @@ int ntfs_resize_attr(ntfs_inode *ino, ntfs_attribute *attr, __s64 newsize) ntfs_bzero((char*)attr->d.data + oldsize, newsize - oldsize); ntfs_memcpy((char*)attr->d.data, v, - min(newsize, oldsize)); + min(s64, newsize, oldsize)); } else attr->d.data = 0; ntfs_free(v); @@ -668,7 +668,7 @@ int ntfs_read_zero(ntfs_io *dest, int size) if (!sparse) return -ENOMEM; while (size) { - int i = min(size, 512); + int i = min(int, size, 512); dest->fn_put(dest, sparse, i); size -= i; } @@ -723,7 +723,7 @@ int ntfs_read_compressed(ntfs_inode *ino, ntfs_attribute *attr, __s64 offset, __s64 l1; if ((len - (s_vcn - vcn)) & 15) ntfs_error("Unexpected sparse chunk size."); - l1 = chunk = min(((__s64)(vcn + len) << clustersizebits) + l1 = chunk = min(s64, ((__s64)(vcn + len) << clustersizebits) - offset, l); error = ntfs_read_zero(dest, l1); if (error) @@ -742,13 +742,13 @@ int ntfs_read_compressed(ntfs_inode *ino, ntfs_attribute *attr, __s64 offset, comp1 = comp; do { io.param = comp1; - l1 = min(len - max(s_vcn - vcn, 0), 16 - got); + l1 = min(int, len - max(int, s_vcn - vcn, 0), 16 - got); io.size = (__s64)l1 << clustersizebits; error = ntfs_getput_clusters(ino->vol, cl1, 0, &io); if (error) goto out; - if (l1 + max(s_vcn - vcn, 0) == len) { + if (l1 + max(int, s_vcn - vcn, 0) == len) { rnum++; rl++; vcn += len; @@ -779,8 +779,8 @@ int ntfs_read_compressed(ntfs_inode *ino, ntfs_attribute *attr, __s64 offset, comp1 = decomp; } offs1 = offset - ((__s64)s_vcn << clustersizebits); - chunk = min((16 << clustersizebits) - offs1, chunk); - chunk = min(l, chunk); + chunk = min(s64, (16 << clustersizebits) - offs1, chunk); + chunk = min(s64, l, chunk); dest->fn_put(dest, comp1 + offs1, chunk); } l -= chunk; diff --git a/fs/ntfs/fs.c b/fs/ntfs/fs.c index 5a618251951b..42659955ecdc 100644 --- a/fs/ntfs/fs.c +++ b/fs/ntfs/fs.c @@ -1048,12 +1048,12 @@ struct super_block * ntfs_read_super(struct super_block *sb, void *options, set_blocksize(sb->s_dev, sb->s_blocksize); ntfs_debug(DEBUG_OTHER, "set_blocksize\n"); /* Allocate an MFT record (MFT record can be smaller than a cluster). */ - if (!(vol->mft = ntfs_malloc(max(vol->mft_record_size, - vol->cluster_size)))) + if (!(vol->mft = ntfs_malloc(max(int, vol->mft_record_size, + vol->cluster_size)))) goto ntfs_read_super_unl; /* Read at least the MFT record for $Mft. */ - for (i = 0; i < max(vol->mft_clusters_per_record, 1); i++) { + for (i = 0; i < max(int, vol->mft_clusters_per_record, 1); i++) { if (!(bh = bread(sb->s_dev, vol->mft_lcn + i, vol->cluster_size))) { ntfs_error("Could not read $Mft record 0\n"); diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 06ea87109e47..bf66e1eb969f 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -105,7 +105,7 @@ static int ntfs_extend_mft(ntfs_volume *vol) * will fall back to the minimal size allocation below. (AIA) */ block = vol->mft_record_size; blockbits = vol->mft_record_size_bits; - size = max(size >> 10, mdata->size + vol->mft_record_size); + size = max(s64, size >> 10, mdata->size + vol->mft_record_size); size = (__s64)((size + block - 1) >> blockbits) << blockbits; /* Require this to be a single chunk. */ error = ntfs_extend_attr(vol->mft_ino, mdata, &size, @@ -394,7 +394,7 @@ static void ntfs_load_attributes(ntfs_inode* ino) io.fn_put = ntfs_put; io.fn_get = 0; io.param = buf + delta; - io.size = len = min(datasize, 1024 - delta); + io.size = len = min(int, datasize, 1024 - delta); ntfs_debug(DEBUG_FILE2, "load_attributes %x: len = %i\n", ino->i_number, len); ntfs_debug(DEBUG_FILE2, "load_attributes %x: delta = %i\n", @@ -729,7 +729,7 @@ int ntfs_readwrite_attr(ntfs_inode *ino, ntfs_attribute *attr, __s64 offset, cluster = attr->d.r.runlist[rnum].cluster; len = attr->d.r.runlist[rnum].len; s_cluster = cluster + s_vcn - vcn; - chunk = min(((__s64)(vcn + len) << clustersizebits) - offset, + chunk = min(s64, ((__s64)(vcn + len) << clustersizebits) - offset, l); dest->size = chunk; error = ntfs_getput_clusters(ino->vol, s_cluster, offset - diff --git a/fs/ntfs/macros.h b/fs/ntfs/macros.h index 829da2579f1b..1210de524f47 100644 --- a/fs/ntfs/macros.h +++ b/fs/ntfs/macros.h @@ -11,12 +11,6 @@ #define NTFS_INO2VOL(ino) (&((ino)->i_sb->u.ntfs_sb)) #define NTFS_LINO2NINO(ino) (&((ino)->u.ntfs_i)) -/* Classical min and max macros still missing in standard headers... */ -#ifndef min -#define min(a,b) ((a) <= (b) ? (a) : (b)) -#define max(a,b) ((a) >= (b) ? (a) : (b)) -#endif - #define IS_MAGIC(a,b) (*(int*)(a) == *(int*)(b)) #define IS_MFT_RECORD(a) IS_MAGIC((a),"FILE") #define IS_INDEX_RECORD(a) IS_MAGIC((a),"INDX") diff --git a/fs/ntfs/support.c b/fs/ntfs/support.c index de4b82f81c02..962378b0832c 100644 --- a/fs/ntfs/support.c +++ b/fs/ntfs/support.c @@ -180,7 +180,7 @@ int ntfs_getput_clusters(ntfs_volume *vol, int cluster, ntfs_size_t start_offs, error = -EIO; goto error_ret; } - to_copy = min(vol->cluster_size - start_offs, length); + to_copy = min(unsigned int, vol->cluster_size - start_offs, length); lock_buffer(bh); if (buf->do_read) { buf->fn_put(buf, bh->b_data + start_offs, to_copy); diff --git a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c index 5908765e9508..e9d5a9effdf3 100644 --- a/fs/ntfs/unistr.c +++ b/fs/ntfs/unistr.c @@ -96,7 +96,7 @@ int ntfs_collate_names(wchar_t *upcase, __u32 upcase_len, __u32 cnt; wchar_t c1, c2; - for (cnt = 0; cnt < min(name1_len, name2_len); ++cnt) + for (cnt = 0; cnt < min(unsigned int, name1_len, name2_len); ++cnt) { c1 = le16_to_cpu(*name1++); c2 = le16_to_cpu(*name2++); diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c index df6eb974be06..41e1841d94ab 100644 --- a/fs/romfs/inode.c +++ b/fs/romfs/inode.c @@ -76,11 +76,6 @@ #include <asm/uaccess.h> -static int inline min(int a, int b) -{ - return a<b ? a : b; -} - static __s32 romfs_checksum(void *data, int size) { @@ -129,7 +124,7 @@ romfs_read_super(struct super_block *s, void *data, int silent) "%s.\n", kdevname(dev)); goto out; } - if (romfs_checksum(rsb, min(sz,512))) { + if (romfs_checksum(rsb, min(int, sz, 512))) { printk ("romfs: bad initial checksum on dev " "%s.\n", kdevname(dev)); goto out; @@ -198,7 +193,7 @@ romfs_strnlen(struct inode *i, unsigned long offset, unsigned long count) return -1; /* error */ avail = ROMBSIZE - (offset & ROMBMASK); - maxsize = min(count, avail); + maxsize = min(unsigned long, count, avail); res = strnlen(((char *)bh->b_data)+(offset&ROMBMASK), maxsize); brelse(bh); @@ -211,7 +206,7 @@ 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(count-res, ROMBSIZE); + maxsize = min(unsigned long, count - res, ROMBSIZE); avail = strnlen(bh->b_data, maxsize); res += avail; brelse(bh); @@ -236,7 +231,7 @@ romfs_copyfrom(struct inode *i, void *dest, unsigned long offset, unsigned long return -1; /* error */ avail = ROMBSIZE - (offset & ROMBMASK); - maxsize = min(count, avail); + maxsize = min(unsigned long, count, avail); memcpy(dest, ((char *)bh->b_data) + (offset & ROMBMASK), maxsize); brelse(bh); @@ -249,7 +244,7 @@ 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(count-res, ROMBSIZE); + maxsize = min(unsigned long, count - res, ROMBSIZE); memcpy(dest, bh->b_data, maxsize); brelse(bh); res += maxsize; @@ -413,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(avail, PAGE_SIZE); + readlen = min(unsigned long, avail, PAGE_SIZE); if (romfs_copyfrom(inode, buf, inode->u.romfs_i.i_dataoffset+offset, readlen) == readlen) { if (readlen < PAGE_SIZE) { memset(buf + readlen,0,PAGE_SIZE-readlen); diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index fa83ba5bee9a..9aa7a9f31fcf 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -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 (inode->u.ufs_i.i_lastfrag, fragment + count); + inode->u.ufs_i.i_lastfrag = max(u32, inode->u.ufs_i.i_lastfrag, fragment + count); NULLIFY_FRAGMENTS } unlock_super(sb); @@ -327,7 +327,7 @@ 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 (inode->u.ufs_i.i_lastfrag, fragment + count); + inode->u.ufs_i.i_lastfrag = max(u32, inode->u.ufs_i.i_lastfrag, fragment + count); NULLIFY_FRAGMENTS unlock_super(sb); UFSD(("EXIT, result %u\n", result)) @@ -380,7 +380,7 @@ 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 (inode->u.ufs_i.i_lastfrag, fragment + count); + inode->u.ufs_i.i_lastfrag = max(u32, inode->u.ufs_i.i_lastfrag, fragment + count); NULLIFY_FRAGMENTS unlock_super(sb); if (newcount < request) diff --git a/fs/ufs/truncate.c b/fs/ufs/truncate.c index d154f58d1687..cae11a7cae69 100644 --- a/fs/ufs/truncate.c +++ b/fs/ufs/truncate.c @@ -88,7 +88,7 @@ static int ufs_trunc_direct (struct inode * inode) retry = 0; frag1 = DIRECT_FRAGMENT; - frag4 = min (UFS_NDIR_FRAGMENT, inode->u.ufs_i.i_lastfrag); + frag4 = min(u32, UFS_NDIR_FRAGMENT, inode->u.ufs_i.i_lastfrag); frag2 = ((frag1 & uspi->s_fpbmask) ? ((frag1 | uspi->s_fpbmask) + 1) : frag1); frag3 = frag4 & ~uspi->s_fpbmask; block1 = block2 = 0; diff --git a/fs/ufs/util.c b/fs/ufs/util.c index 54a0ab80f59a..9380ccbc6b17 100644 --- a/fs/ufs/util.c +++ b/fs/ufs/util.c @@ -166,11 +166,11 @@ void _ubh_ubhcpymem_(struct ufs_sb_private_info * uspi, unsigned char * mem, struct ufs_buffer_head * ubh, unsigned size) { unsigned len, bhno; - if ( size > (ubh->count << uspi->s_fshift) ) + if (size > (ubh->count << uspi->s_fshift)) size = ubh->count << uspi->s_fshift; bhno = 0; - while ( size ) { - len = min (size, uspi->s_fsize); + while (size) { + len = min(unsigned int, size, uspi->s_fsize); memcpy (mem, ubh->bh[bhno]->b_data, len); mem += uspi->s_fsize; size -= len; @@ -182,11 +182,11 @@ void _ubh_memcpyubh_(struct ufs_sb_private_info * uspi, struct ufs_buffer_head * ubh, unsigned char * mem, unsigned size) { unsigned len, bhno; - if ( size > (ubh->count << uspi->s_fshift) ) + if (size > (ubh->count << uspi->s_fshift)) size = ubh->count << uspi->s_fshift; bhno = 0; - while ( size ) { - len = min (size, uspi->s_fsize); + while (size) { + len = min(unsigned int, size, uspi->s_fsize); memcpy (ubh->bh[bhno]->b_data, mem, len); mem += uspi->s_fsize; size -= len; diff --git a/fs/ufs/util.h b/fs/ufs/util.h index 0def49d959a9..a1e5889d0bb5 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h @@ -14,10 +14,6 @@ * some useful macros */ #define in_range(b,first,len) ((b)>=(first)&&(b)<(first)+(len)) -#define min(x,y) ((x)<(y)?(x):(y)) -#define max(x,y) ((x)>(y)?(x):(y)) - - /* * macros used for retyping @@ -335,7 +331,7 @@ static inline unsigned _ubh_find_next_zero_bit_( base = offset >> uspi->s_bpfshift; offset &= uspi->s_bpfmask; for (;;) { - count = min (size + offset, uspi->s_bpf); + count = min(unsigned int, size + offset, uspi->s_bpf); size -= count - offset; pos = ext2_find_next_zero_bit (ubh->bh[base]->b_data, count, offset); if (pos < count || !size) @@ -382,7 +378,8 @@ static inline unsigned _ubh_find_last_zero_bit_( base = start >> uspi->s_bpfshift; start &= uspi->s_bpfmask; for (;;) { - count = min (size + (uspi->s_bpf - start), uspi->s_bpf) + count = min(unsigned int, + size + (uspi->s_bpf - start), uspi->s_bpf) - (uspi->s_bpf - start); size -= count; pos = find_last_zero_bit (ubh->bh[base]->b_data, diff --git a/include/asm-sparc/hw_irq.h b/include/asm-sparc/hw_irq.h new file mode 100644 index 000000000000..8d30a7694be2 --- /dev/null +++ b/include/asm-sparc/hw_irq.h @@ -0,0 +1,6 @@ +#ifndef __ASM_SPARC_HW_IRQ_H +#define __ASM_SPARC_HW_IRQ_H + +/* Dummy include. */ + +#endif diff --git a/include/asm-sparc64/hw_irq.h b/include/asm-sparc64/hw_irq.h new file mode 100644 index 000000000000..153cae2ddaee --- /dev/null +++ b/include/asm-sparc64/hw_irq.h @@ -0,0 +1,6 @@ +#ifndef __ASM_SPARC64_HW_IRQ_H +#define __ASM_SPARC64_HW_IRQ_H + +/* Dummy include. */ + +#endif diff --git a/include/asm-sparc64/keyboard.h b/include/asm-sparc64/keyboard.h index 15f24c33f5a4..1813bed622c6 100644 --- a/include/asm-sparc64/keyboard.h +++ b/include/asm-sparc64/keyboard.h @@ -1,4 +1,4 @@ -/* $Id: keyboard.h,v 1.3 1999/04/28 11:59:12 davem Exp $ +/* $Id: keyboard.h,v 1.4 2001/08/13 14:40:07 davem Exp $ * linux/include/asm-sparc64/keyboard.h * * Created Aug 29 1997 by Eddie C. Dost (ecd@skynet.be) @@ -13,6 +13,9 @@ #ifdef __KERNEL__ +#include <linux/kernel.h> +#include <linux/kd.h> + #define KEYBOARD_IRQ 1 #define DISABLE_KBD_DURING_INTERRUPTS 0 @@ -22,6 +25,7 @@ extern int pcikbd_translate(unsigned char scancode, unsigned char *keycode, char raw_mode); extern char pcikbd_unexpected_up(unsigned char keycode); extern void pcikbd_leds(unsigned char leds); +extern int pcikbd_rate(struct kbd_repeat *rep); extern void pcikbd_init_hw(void); extern unsigned char pcikbd_sysrq_xlate[128]; @@ -30,6 +34,7 @@ extern unsigned char pcikbd_sysrq_xlate[128]; #define kbd_translate pcikbd_translate #define kbd_unexpected_up pcikbd_unexpected_up #define kbd_leds pcikbd_leds +#define kbd_rate pcikbd_rate #define kbd_init_hw pcikbd_init_hw #define kbd_sysrq_xlate pcikbd_sysrq_xlate #define kbd_init pcikbd_init diff --git a/include/asm-sparc64/mmu_context.h b/include/asm-sparc64/mmu_context.h index 76e23b44d07d..357d0e7ef763 100644 --- a/include/asm-sparc64/mmu_context.h +++ b/include/asm-sparc64/mmu_context.h @@ -1,4 +1,4 @@ -/* $Id: mmu_context.h,v 1.49 2001/08/09 21:10:20 davem Exp $ */ +/* $Id: mmu_context.h,v 1.50 2001/08/13 20:24:34 kanoj Exp $ */ #ifndef __SPARC64_MMU_CONTEXT_H #define __SPARC64_MMU_CONTEXT_H @@ -9,6 +9,7 @@ #include <linux/spinlock.h> #include <asm/system.h> #include <asm/spitfire.h> +#include <asm/page.h> static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk, unsigned cpu) { @@ -18,7 +19,19 @@ extern spinlock_t ctx_alloc_lock; extern unsigned long tlb_context_cache; extern unsigned long mmu_context_bmap[]; -#define CTX_VERSION_SHIFT (PAGE_SHIFT - 3) +/* + * For the 8k pagesize kernel, use only 10 hw context bits to optimize some shifts in + * the fast tlbmiss handlers, instead of all 13 bits (specifically for vpte offset + * calculation). For other pagesizes, this optimization in the tlbhandlers can not be + * done; but still, all 13 bits can not be used because the tlb handlers use "andcc" + * instruction which sign extends 13 bit arguments. + */ +#if PAGE_SHIFT == 13 +#define CTX_VERSION_SHIFT 10 +#else +#define CTX_VERSION_SHIFT 12 +#endif + #define CTX_VERSION_MASK ((~0UL) << CTX_VERSION_SHIFT) #define CTX_FIRST_VERSION ((1UL << CTX_VERSION_SHIFT) + 1UL) #define CTX_VALID(__ctx) \ diff --git a/include/asm-sparc64/pbm.h b/include/asm-sparc64/pbm.h index 7e4fb85ac9d9..af595343fefc 100644 --- a/include/asm-sparc64/pbm.h +++ b/include/asm-sparc64/pbm.h @@ -1,4 +1,4 @@ -/* $Id: pbm.h,v 1.26 2001/05/15 08:54:30 davem Exp $ +/* $Id: pbm.h,v 1.27 2001/08/12 13:18:23 davem Exp $ * pbm.h: UltraSparc PCI controller software state. * * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@redhat.com) @@ -157,6 +157,9 @@ struct pci_pbm_info { /* IOMMU state, potentially shared by both PBM segments. */ struct pci_iommu *iommu; + /* PCI slot mapping. */ + unsigned int pci_first_slot; + /* Now things for the actual PCI bus probes. */ unsigned int pci_first_busno; unsigned int pci_last_busno; diff --git a/include/asm-sparc64/pgtable.h b/include/asm-sparc64/pgtable.h index 614fec33f339..3b506d4146ad 100644 --- a/include/asm-sparc64/pgtable.h +++ b/include/asm-sparc64/pgtable.h @@ -1,4 +1,4 @@ -/* $Id: pgtable.h,v 1.140 2001/04/12 22:41:15 davem Exp $ +/* $Id: pgtable.h,v 1.141 2001/08/13 20:24:34 kanoj Exp $ * pgtable.h: SpitFire page table operations. * * Copyright 1996,1997 David S. Miller (davem@caip.rutgers.edu) @@ -16,6 +16,7 @@ #include <asm/asi.h> #include <asm/mmu_context.h> #include <asm/system.h> +#include <asm/page.h> #ifndef __ASSEMBLY__ @@ -31,14 +32,26 @@ * XXX cheetah's full 64-bit virtual address space, ie. no more hole * XXX in the middle like on spitfire. -DaveM */ +/* + * Given a virtual address, the lowest PAGE_SHIFT bits determine offset + * into the page; the next higher PAGE_SHIFT-3 bits determine the pte# + * in the proper pagetable (the -3 is from the 8 byte ptes, and each page + * table is a single page long). The next higher PMD_BITS determine pmd# + * in the proper pmdtable (where we must have PMD_BITS <= (PAGE_SHIFT-2) + * since the pmd entries are 4 bytes, and each pmd page is a single page + * long). Finally, the higher few bits determine pgde#. + */ + +#define VA_BITS 44 /* PMD_SHIFT determines the size of the area a second-level page table can map */ #define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3)) #define PMD_SIZE (1UL << PMD_SHIFT) #define PMD_MASK (~(PMD_SIZE-1)) +#define PMD_BITS 11 /* PGDIR_SHIFT determines what a third-level page table entry can map */ -#define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3) + (PAGE_SHIFT-2)) +#define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3) + PMD_BITS) #define PGDIR_SIZE (1UL << PGDIR_SHIFT) #define PGDIR_MASK (~(PGDIR_SIZE-1)) @@ -48,12 +61,12 @@ /* We the first one in this file, what we export to the kernel * is different so we can optimize correctly for 32-bit tasks. */ -#define REAL_PTRS_PER_PMD (1UL << (PAGE_SHIFT-2)) +#define REAL_PTRS_PER_PMD (1UL << PMD_BITS) #define PTRS_PER_PMD ((const int)((current->thread.flags & SPARC_FLAG_32BIT) ? \ - (REAL_PTRS_PER_PMD >> 2) : (REAL_PTRS_PER_PMD))) + (1UL << (32 - (PAGE_SHIFT-3) - PAGE_SHIFT)) : (REAL_PTRS_PER_PMD))) /* We cannot use the top 16G because VPTE table lives there. */ -#define PTRS_PER_PGD ((1UL << (PAGE_SHIFT-3))-1) +#define PTRS_PER_PGD ((1UL << (VA_BITS - PAGE_SHIFT - (PAGE_SHIFT-3) - PMD_BITS))-1) /* Kernel has a separate 44bit address space. */ #define USER_PTRS_PER_PGD ((const int)((current->thread.flags & SPARC_FLAG_32BIT) ? \ @@ -62,7 +75,6 @@ #define PTE_TABLE_SIZE 0x2000 /* 1024 entries 8 bytes each */ #define PMD_TABLE_SIZE 0x2000 /* 2048 entries 4 bytes each */ -#define PGD_TABLE_SIZE 0x1000 /* 1024 entries 4 bytes each */ /* NOTE: TLB miss handlers depend heavily upon where this is. */ #define VMALLOC_START 0x0000000140000000UL diff --git a/include/linux/cyclomx.h b/include/linux/cyclomx.h index 555d38fbeed6..1d39011731b6 100644 --- a/include/linux/cyclomx.h +++ b/include/linux/cyclomx.h @@ -37,13 +37,6 @@ #include <linux/cycx_x25.h> #endif -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef max -#define max(a,b) (((a)>(b))?(a):(b)) -#endif - #define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0) /* Adapter Data Space. diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 6f1882dbaeb5..bafb80e8cae2 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -112,6 +112,11 @@ static inline void console_verbose(void) ((unsigned char *)&addr)[1], \ ((unsigned char *)&addr)[0] +#define min(type,x,y) \ + ({ type __x = (x), __y = (y); __x < __y ? __x: __y; }) +#define max(type,x,y) \ + ({ type __x = (x), __y = (y); __x > __y ? __x: __y; }) + #endif /* __KERNEL__ */ #define SI_LOAD_SHIFT 16 diff --git a/include/linux/lvm.h b/include/linux/lvm.h index 6aa20e4ccf64..e4f6c1f44a3b 100644 --- a/include/linux/lvm.h +++ b/include/linux/lvm.h @@ -131,13 +131,6 @@ #define LVM_DIR_PREFIX "/dev/" -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef max -#define max(a,b) (((a)>(b))?(a):(b)) -#endif - /* set the default structure version */ #if ( LVM_STRUCT_VERSION == 1) #define pv_t pv_v2_t diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h index d32afe265335..3424ef2bc70e 100644 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h @@ -365,10 +365,6 @@ static inline __u8 cfi_read_query(struct map_info *map, __u32 addr) } } -#ifndef min -#define min(x,y) ( (x)<(y)?(x):(y) ) -#endif - static inline void cfi_udelay(int us) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 0219a979a95f..64d9850695a9 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -63,6 +63,11 @@ */ #define NFS_SUPER_MAGIC 0x6969 +static inline struct nfs_inode_info *NFS_I(struct inode *inode) +{ + return &inode->u.nfs_i; +} + #define NFS_FH(inode) (&(inode)->u.nfs_i.fh) #define NFS_SERVER(inode) (&(inode)->i_sb->u.nfs_sb.s_server) #define NFS_CLIENT(inode) (NFS_SERVER(inode)->client) @@ -74,7 +79,6 @@ #define NFS_READTIME(inode) ((inode)->u.nfs_i.read_cache_jiffies) #define NFS_CACHE_CTIME(inode) ((inode)->u.nfs_i.read_cache_ctime) #define NFS_CACHE_MTIME(inode) ((inode)->u.nfs_i.read_cache_mtime) -#define NFS_CACHE_ATIME(inode) ((inode)->u.nfs_i.read_cache_atime) #define NFS_CACHE_ISIZE(inode) ((inode)->u.nfs_i.read_cache_isize) #define NFS_NEXTSCAN(inode) ((inode)->u.nfs_i.nextscan) #define NFS_CACHEINV(inode) \ diff --git a/include/linux/nfs_fs_i.h b/include/linux/nfs_fs_i.h index f14f3d8d9c8e..2903f4c83b6c 100644 --- a/include/linux/nfs_fs_i.h +++ b/include/linux/nfs_fs_i.h @@ -45,7 +45,6 @@ struct nfs_inode_info { unsigned long read_cache_jiffies; __u64 read_cache_ctime; __u64 read_cache_mtime; - __u64 read_cache_atime; __u64 read_cache_isize; unsigned long attrtimeo; unsigned long attrtimeo_timestamp; @@ -73,6 +72,9 @@ struct nfs_inode_info { struct inode *hash_next, *hash_prev; unsigned long nextscan; + + /* Credentials for shared mmap */ + struct rpc_cred *mm_cred; }; /* diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index d66474b60c42..9ea631ace800 100644 --- a/include/linux/sunrpc/auth.h +++ b/include/linux/sunrpc/auth.h @@ -14,6 +14,8 @@ #include <linux/config.h> #include <linux/sunrpc/sched.h> +#include <asm/atomic.h> + /* size of the nodename buffer */ #define UNX_MAXNODENAME 32 @@ -22,8 +24,10 @@ */ struct rpc_cred { struct rpc_cred * cr_next; /* linked list */ + struct rpc_auth * cr_auth; + struct rpc_credops * cr_ops; unsigned long cr_expire; /* when to gc */ - unsigned short cr_count; /* ref count */ + atomic_t cr_count; /* ref count */ unsigned short cr_flags; /* various flags */ #ifdef RPC_DEBUG unsigned long cr_magic; /* 0x0f4aa4f0 */ @@ -71,6 +75,9 @@ struct rpc_authops { void (*destroy)(struct rpc_auth *); struct rpc_cred * (*crcreate)(int); +}; + +struct rpc_credops { void (*crdestroy)(struct rpc_cred *); int (*crmatch)(struct rpc_cred *, int); @@ -92,8 +99,7 @@ void rpcauth_destroy(struct rpc_auth *); struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); struct rpc_cred * rpcauth_bindcred(struct rpc_task *); void rpcauth_holdcred(struct rpc_task *); -void rpcauth_releasecred(struct rpc_auth *, - struct rpc_cred *); +void put_rpccred(struct rpc_cred *); void rpcauth_unbindcred(struct rpc_task *); int rpcauth_matchcred(struct rpc_auth *, struct rpc_cred *, int); @@ -107,5 +113,12 @@ void rpcauth_free_credcache(struct rpc_auth *); void rpcauth_insert_credcache(struct rpc_auth *, struct rpc_cred *); +static inline +struct rpc_cred * get_rpccred(struct rpc_cred *cred) +{ + atomic_inc(&cred->cr_count); + return cred; +} + #endif /* __KERNEL__ */ #endif /* _LINUX_SUNRPC_AUTH_H */ diff --git a/include/linux/swap.h b/include/linux/swap.h index dd83dac6be0d..26619cf335af 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -256,9 +256,9 @@ extern spinlock_t pagemap_lru_lock; * 64 (1 << INACTIVE_SHIFT) seconds. */ #define INACTIVE_SHIFT 6 -#define inactive_min(a,b) ((a) < (b) ? (a) : (b)) -#define inactive_target inactive_min((memory_pressure >> INACTIVE_SHIFT), \ - (num_physpages / 4)) +#define inactive_target min(unsigned long, \ + (memory_pressure >> INACTIVE_SHIFT), \ + (num_physpages / 4)) /* * Ugly ugly ugly HACK to make sure the inactive lists diff --git a/include/linux/wanpipe.h b/include/linux/wanpipe.h index b1954a442bce..061090a368f8 100644 --- a/include/linux/wanpipe.h +++ b/include/linux/wanpipe.h @@ -332,13 +332,6 @@ typedef struct { #include <linux/tty_flip.h> -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef max -#define max(a,b) (((a)>(b))?(a):(b)) -#endif - #define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0) #define is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')||\ ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0) diff --git a/include/net/sock.h b/include/net/sock.h index bc2a1192e50b..403e842f6d78 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -803,26 +803,6 @@ do { spin_lock_bh(&((__sk)->lock.slock)); \ #define bh_lock_sock(__sk) spin_lock(&((__sk)->lock.slock)) #define bh_unlock_sock(__sk) spin_unlock(&((__sk)->lock.slock)) -/* - * This might not be the most appropriate place for this two - * but since they are used by a lot of the net related code - * at least they get declared on a include that is common to all - */ - -static __inline__ int min(unsigned int a, unsigned int b) -{ - if (a > b) - a = b; - return a; -} - -static __inline__ int max(unsigned int a, unsigned int b) -{ - if (a < b) - a = b; - return a; -} - extern struct sock * sk_alloc(int family, int priority, int zero_it); extern void sk_free(struct sock *sk); @@ -1265,7 +1245,7 @@ static inline long sock_sndtimeo(struct sock *sk, int noblock) static inline int sock_rcvlowat(struct sock *sk, int waitall, int len) { - return (waitall ? len : min(sk->rcvlowat, len)) ? : 1; + return (waitall ? len : min(int, sk->rcvlowat, len)) ? : 1; } /* Alas, with timeout socket operations are not restartable. diff --git a/include/net/tcp.h b/include/net/tcp.h index e7f459819865..8edcd920facd 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -919,11 +919,14 @@ 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; - int hint = min(tp->advmss, tp->mss_cache); + unsigned int hint = min(unsigned int, tp->advmss, tp->mss_cache); - hint = min(hint, tp->rcv_wnd/2); + hint = min(unsigned int, hint, tp->rcv_wnd/2); - tp->ack.rcv_mss = max(min(hint, TCP_MIN_RCVMSS), TCP_MIN_MSS); + tp->ack.rcv_mss = max(unsigned int, + min(unsigned int, + hint, TCP_MIN_RCVMSS), + TCP_MIN_MSS); } static __inline__ void __tcp_fast_path_on(struct tcp_opt *tp, u32 snd_wnd) @@ -1074,7 +1077,7 @@ static __inline__ int tcp_packets_in_flight(struct tcp_opt *tp) */ static inline __u32 tcp_recalc_ssthresh(struct tcp_opt *tp) { - return max(tp->snd_cwnd>>1, 2); + return max(u32, tp->snd_cwnd >> 1, 2); } /* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. @@ -1086,7 +1089,9 @@ 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(tp->snd_ssthresh, (tp->snd_cwnd>>1)+(tp->snd_cwnd>>2)); + return max(u32, tp->snd_ssthresh, + ((tp->snd_cwnd >> 1) + + (tp->snd_cwnd >> 2))); } static inline void tcp_sync_left_out(struct tcp_opt *tp) @@ -1121,7 +1126,8 @@ 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(tp->snd_cwnd, tcp_packets_in_flight(tp)+1); + tp->snd_cwnd = min(u32, tp->snd_cwnd, + tcp_packets_in_flight(tp) + 1); tp->snd_cwnd_cnt = 0; tp->high_seq = tp->snd_nxt; tp->snd_cwnd_stamp = tcp_time_stamp; @@ -1486,12 +1492,12 @@ 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(*window_clamp,space); + (*window_clamp) = (65535 << 14); + space = min(u32, *window_clamp, space); /* Quantize space offering to a multiple of mss if possible. */ if (space > mss) - space = (space/mss)*mss; + space = (space / mss) * mss; /* NOTE: offering an initial window larger than 32767 * will break some buggy TCP stacks. We try to be nice. @@ -1499,7 +1505,7 @@ 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(space, MAX_TCP_WINDOW); + (*rcv_wnd) = min(int, space, MAX_TCP_WINDOW); (*rcv_wscale) = 0; if (wscale_ok) { /* See RFC1323 for an explanation of the limit to 14 */ @@ -1508,7 +1514,7 @@ static inline void tcp_select_initial_window(int space, __u32 mss, (*rcv_wscale)++; } if (*rcv_wscale && sysctl_tcp_app_win && space>=mss && - space - max((space>>sysctl_tcp_app_win), mss>>*rcv_wscale) < 65536/2) + space - max(unsigned int, (space>>sysctl_tcp_app_win), mss>>*rcv_wscale) < 65536/2) (*rcv_wscale)--; } @@ -1526,7 +1532,7 @@ 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(65535<<(*rcv_wscale),*window_clamp); + (*window_clamp) = min(u32, 65535 << (*rcv_wscale), *window_clamp); } static inline int tcp_win_from_space(int space) @@ -1692,8 +1698,8 @@ static inline void tcp_enter_memory_pressure(void) static inline void tcp_moderate_sndbuf(struct sock *sk) { if (!(sk->userlocks&SOCK_SNDBUF_LOCK)) { - sk->sndbuf = min(sk->sndbuf, sk->wmem_queued/2); - sk->sndbuf = max(sk->sndbuf, SOCK_MIN_SNDBUF); + sk->sndbuf = min(int, sk->sndbuf, sk->wmem_queued/2); + sk->sndbuf = max(int, sk->sndbuf, SOCK_MIN_SNDBUF); } } diff --git a/mm/filemap.c b/mm/filemap.c index 3ba39b97dd6a..aa1072b04bca 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -45,12 +45,12 @@ atomic_t page_cache_size = ATOMIC_INIT(0); unsigned int page_hash_bits; struct page **page_hash_table; -spinlock_t pagecache_lock = SPIN_LOCK_UNLOCKED; +spinlock_t __cacheline_aligned pagecache_lock = SPIN_LOCK_UNLOCKED; /* * NOTE: to avoid deadlocking you must never acquire the pagecache_lock with * the pagemap_lru_lock held. */ -spinlock_t pagemap_lru_lock = SPIN_LOCK_UNLOCKED; +spinlock_t __cacheline_aligned pagemap_lru_lock = SPIN_LOCK_UNLOCKED; #define CLUSTER_PAGES (1 << page_cluster) #define CLUSTER_OFFSET(x) (((x) >> page_cluster) << page_cluster) diff --git a/mm/highmem.c b/mm/highmem.c index 5f3cef59c05f..a54e4e4372aa 100644 --- a/mm/highmem.c +++ b/mm/highmem.c @@ -46,7 +46,7 @@ static void flush_all_zero_pkmaps(void) for (i = 0; i < LAST_PKMAP; i++) { struct page *page; - pte_t pte; + /* * zero means we don't have anything to do, * >1 means that it is still in use. Only @@ -56,10 +56,21 @@ static void flush_all_zero_pkmaps(void) if (pkmap_count[i] != 1) continue; pkmap_count[i] = 0; - pte = ptep_get_and_clear(pkmap_page_table+i); - if (pte_none(pte)) + + /* sanity check */ + if (pte_none(pkmap_page_table[i])) BUG(); - page = pte_page(pte); + + /* + * Don't need an atomic fetch-and-clear op here; + * no-one has the page mapped, and cannot get at + * its virtual address (and hence PTE) without first + * getting the kmap_lock (which is held here). + * So no dangers, even with speculative execution. + */ + page = pte_page(pkmap_page_table[i]); + pte_clear(&pkmap_page_table[i]); + page->virtual = NULL; } flush_tlb_all(); @@ -139,6 +150,7 @@ void kunmap_high(struct page *page) { unsigned long vaddr; unsigned long nr; + int need_wakeup; spin_lock(&kmap_lock); vaddr = (unsigned long) page->virtual; @@ -150,13 +162,28 @@ void kunmap_high(struct page *page) * A count must never go down to zero * without a TLB flush! */ + need_wakeup = 0; switch (--pkmap_count[nr]) { case 0: BUG(); case 1: - wake_up(&pkmap_map_wait); + /* + * Avoid an unnecessary wake_up() function call. + * The common case is pkmap_count[] == 1, but + * no waiters. + * The tasks queued in the wait-queue are guarded + * by both the lock in the wait-queue-head and by + * the kmap_lock. As the kmap_lock is held here, + * no need for the wait-queue-head's lock. Simply + * test if the queue is empty. + */ + need_wakeup = waitqueue_active(&pkmap_map_wait); } spin_unlock(&kmap_lock); + + /* do wake-up, if needed, race-free outside of the spin lock */ + if (need_wakeup) + wake_up(&pkmap_map_wait); } #define POOL_SIZE 32 @@ -182,20 +209,12 @@ static inline void copy_from_high_bh (struct buffer_head *to, { struct page *p_from; char *vfrom; - unsigned long flags; p_from = from->b_page; - /* - * Since this can be executed from IRQ context, reentrance - * on the same CPU must be avoided: - */ - __save_flags(flags); - __cli(); vfrom = kmap_atomic(p_from, KM_BOUNCE_WRITE); memcpy(to->b_data, vfrom + bh_offset(from), to->b_size); kunmap_atomic(vfrom, KM_BOUNCE_WRITE); - __restore_flags(flags); } static inline void copy_to_high_bh_irq (struct buffer_head *to, diff --git a/mm/vmscan.c b/mm/vmscan.c index cc1a556e9f21..1dfb9d1b76a0 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -788,6 +788,9 @@ int inactive_shortage(void) zone_t *zone = pgdat->node_zones + i; unsigned int inactive; + if (!zone->size) + continue; + inactive = zone->inactive_dirty_pages; inactive += zone->inactive_clean_pages; inactive += zone->free_pages; diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index d1a1ecf4893a..d40aefcfd712 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -113,8 +113,6 @@ extern inline void atalk_unregister_sysctl(void); struct datalink_proto *ddp_dl, *aarp_dl; static struct proto_ops atalk_dgram_ops; -#define min(a,b) (((a)<(b))?(a):(b)) - /**************************************************************************\ * * * Handlers for the socket list. * @@ -1392,7 +1390,7 @@ 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(skb->len, ddphv.deh_len)); + skb_trim(skb, min(unsigned int, skb->len, ddphv.deh_len)); /* * Size check to see if ddp->deh_len was crap @@ -1457,7 +1455,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, } /* Fix up skb->len field */ - skb_trim(skb, min(origlen, rt->dev->hard_header_len + + skb_trim(skb, min(unsigned int, origlen, rt->dev->hard_header_len + ddp_dl->header_length + ddphv.deh_len)); /* Mend the byte order */ diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 1d767b9d7d50..da409ee20946 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -751,7 +751,7 @@ static int ax25_getsockopt(struct socket *sock, int level, int optname, char *op return -EFAULT; valptr = (void *) &val; - length = min(maxlen, sizeof(int)); + length = min(unsigned int, maxlen, sizeof(int)); switch (optname) { case AX25_WINDOW: @@ -803,7 +803,7 @@ 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(strlen(ax25_dev->dev->name)+1, maxlen); + length = min(unsigned int, strlen(ax25_dev->dev->name)+1, maxlen); devname[length-1] = '\0'; } else { *devname = '\0'; diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 3d047851d952..95772a1e3dc6 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -5,7 +5,7 @@ * Authors: * Lennert Buytenhek <buytenh@gnu.org> * - * $Id: br_device.c,v 1.4 2001/06/01 09:28:28 davem Exp $ + * $Id: br_device.c,v 1.5 2001/08/14 22:05:57 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -53,7 +53,8 @@ static int __br_dev_xmit(struct sk_buff *skb, struct net_device *dev) br->statistics.tx_packets++; br->statistics.tx_bytes += skb->len; - dest = skb->data; + dest = skb->mac.raw = skb->data; + skb_pull(skb, ETH_HLEN); if (dest[0] & 1) { br_flood_deliver(br, skb, 0); diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index a3de3ed57ca5..405c44c90724 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c @@ -5,7 +5,7 @@ * Authors: * Lennert Buytenhek <buytenh@gnu.org> * - * $Id: br_forward.c,v 1.3 2001/06/01 09:28:28 davem Exp $ + * $Id: br_forward.c,v 1.4 2001/08/14 22:05:57 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,10 +30,18 @@ static inline int should_deliver(struct net_bridge_port *p, struct sk_buff *skb) return 1; } +static int __dev_queue_push_xmit(struct sk_buff *skb) +{ + skb_push(skb, ETH_HLEN); + dev_queue_xmit(skb); + + return 0; +} + static int __br_forward_finish(struct sk_buff *skb) { NF_HOOK(PF_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev, - dev_queue_xmit); + __dev_queue_push_xmit); return 0; } diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index d76a6ba8b026..dc1e1561a051 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -5,7 +5,7 @@ * Authors: * Lennert Buytenhek <buytenh@gnu.org> * - * $Id: br_input.c,v 1.8 2001/06/01 09:28:28 davem Exp $ + * $Id: br_input.c,v 1.9 2001/08/14 22:05:57 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -39,7 +39,7 @@ static void br_pass_frame_up(struct net_bridge *br, struct sk_buff *skb) indev = skb->dev; skb->dev = &br->dev; skb->pkt_type = PACKET_HOST; - skb_pull(skb, skb->mac.raw - skb->data); + skb_push(skb, ETH_HLEN); skb->protocol = eth_type_trans(skb, &br->dev); NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL, @@ -64,8 +64,6 @@ static void __br_handle_frame(struct sk_buff *skb) p->state == BR_STATE_DISABLED) goto freeandout; - skb_push(skb, skb->data - skb->mac.raw); - if (br->dev.flags & IFF_PROMISC) { struct sk_buff *skb2; diff --git a/net/core/iovec.c b/net/core/iovec.c index d12468d7c4f6..50f4395724df 100644 --- a/net/core/iovec.c +++ b/net/core/iovec.c @@ -87,7 +87,7 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len) { if(iov->iov_len) { - int copy = min(iov->iov_len, len); + int copy = min(unsigned int, iov->iov_len, len); if (copy_to_user(iov->iov_base, kdata, copy)) goto out; kdata+=copy; @@ -114,7 +114,7 @@ void memcpy_tokerneliovec(struct iovec *iov, unsigned char *kdata, int len) { if(iov->iov_len) { - int copy = min(iov->iov_len, len); + int copy = min(unsigned int, iov->iov_len, len); memcpy(iov->iov_base, kdata, copy); kdata+=copy; len-=copy; @@ -140,7 +140,7 @@ int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len) { if(iov->iov_len) { - int copy = min(len, iov->iov_len); + int copy = min(unsigned int, len, iov->iov_len); if (copy_from_user(kdata, iov->iov_base, copy)) goto out; len-=copy; @@ -175,7 +175,7 @@ int memcpy_fromiovecend(unsigned char *kdata, struct iovec *iov, int offset, while (len > 0) { u8 *base = iov->iov_base + offset; - int copy = min(len, iov->iov_len - offset); + int copy = min(unsigned int, len, iov->iov_len - offset); offset = 0; if (copy_from_user(kdata, base, copy)) @@ -214,7 +214,7 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov, while (len > 0) { u8 *base = iov->iov_base + offset; - unsigned int copy = min(len, iov->iov_len - offset); + int copy = min(unsigned int, len, iov->iov_len - offset); offset = 0; /* There is a remnant from previous iov. */ diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 43db547adc96..51b99b08826f 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -5,7 +5,7 @@ * * The IP to API glue. * - * Version: $Id: ip_sockglue.c,v 1.56 2001/02/18 09:07:58 davem Exp $ + * Version: $Id: ip_sockglue.c,v 1.59 2001/08/13 18:56:12 davem Exp $ * * Authors: see ip.c * @@ -43,8 +43,6 @@ #include <linux/errqueue.h> #include <asm/uaccess.h> -#define MAX(a,b) ((a)>(b)?(a):(b)) - #define IP_CMSG_PKTINFO 1 #define IP_CMSG_TTL 2 #define IP_CMSG_TOS 4 @@ -685,7 +683,7 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op ip_options_undo(opt); - len=min(len, opt->optlen); + len = min(unsigned int, len, opt->optlen); if(put_user(len, optlen)) return -EFAULT; if(copy_to_user(optval, opt->__data, len)) @@ -746,7 +744,7 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op case IP_MULTICAST_IF: { struct in_addr addr; - len = min(len,sizeof(struct in_addr)); + len = min(unsigned int, len, sizeof(struct in_addr)); addr.s_addr = sk->protinfo.af_inet.mc_addr; release_sock(sk); @@ -810,7 +808,7 @@ 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(sizeof(int),len); + len = min(unsigned int, sizeof(int), len); if(put_user(len, optlen)) return -EFAULT; if(copy_to_user(optval,&val,len)) diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 6a696b74cf24..bc736375167e 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -9,7 +9,7 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * - * Version: $Id: ipmr.c,v 1.60 2001/06/29 21:33:22 davem Exp $ + * Version: $Id: ipmr.c,v 1.63 2001/08/13 18:56:12 davem Exp $ * * Fixes: * Michael Chastain : Incorrect size of copying. @@ -976,11 +976,11 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char *optval,int *optlen) optname!=MRT_ASSERT) return -ENOPROTOOPT; - if(get_user(olr, optlen)) + if (get_user(olr, optlen)) return -EFAULT; - olr=min(olr,sizeof(int)); - if(olr<0) + olr = min(unsigned int, olr, sizeof(int)); + if (olr < 0) return -EINVAL; if(put_user(olr,optlen)) diff --git a/net/ipv4/netfilter/ipchains_core.c b/net/ipv4/netfilter/ipchains_core.c index 9c3434aa50d3..186e63ee3cf0 100644 --- a/net/ipv4/netfilter/ipchains_core.c +++ b/net/ipv4/netfilter/ipchains_core.c @@ -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(f->ipfw.fw_outputsize, ntohs(ip->tot_len)) + size_t len = min(unsigned int, f->ipfw.fw_outputsize, ntohs(ip->tot_len)) + sizeof(__u32) + sizeof(skb->nfmark) + IFNAMSIZ; struct sk_buff *outskb=alloc_skb(len, GFP_ATOMIC); diff --git a/net/ipv4/netfilter/ipfwadm_core.c b/net/ipv4/netfilter/ipfwadm_core.c index b1ec4cbfda11..d59d540533b2 100644 --- a/net/ipv4/netfilter/ipfwadm_core.c +++ b/net/ipv4/netfilter/ipfwadm_core.c @@ -20,7 +20,7 @@ * license in recognition of the original copyright. * -- Alan Cox. * - * $Id: ipfwadm_core.c,v 1.5 2001/06/01 14:56:53 davem Exp $ + * $Id: ipfwadm_core.c,v 1.8 2001/08/13 18:56:12 davem Exp $ * * Ported from BSD to Linux, * Alan Cox 22/Nov/1994. @@ -648,7 +648,9 @@ 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(128,ntohs(ip->tot_len)); + int len = min(unsigned int, + 128, ntohs(ip->tot_len)); + skb_put(skb,len); memcpy(skb->data,ip,len); if(netlink_post(NETLINK_FIREWALL, skb)) diff --git a/net/ipv4/route.c b/net/ipv4/route.c index d5bed1ea9c43..e5432e639c09 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -5,7 +5,7 @@ * * ROUTE - implementation of the IP router. * - * Version: $Id: route.c,v 1.95 2001/07/10 22:32:51 davem Exp $ + * Version: $Id: route.c,v 1.98 2001/08/13 18:56:12 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -515,14 +515,14 @@ 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(goal / 2, rt_hash_mask + 1); + equilibrium += min(unsigned int, goal / 2, rt_hash_mask + 1); goal = atomic_read(&ipv4_dst_ops.entries) - equilibrium; } } else { /* We are in dangerous area. Try to reduce cache really * aggressively. */ - goal = max(goal / 2, rt_hash_mask + 1); + goal = max(unsigned int, goal / 2, rt_hash_mask + 1); equilibrium = atomic_read(&ipv4_dst_ops.entries) - goal; } @@ -1207,8 +1207,8 @@ 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(rt->u.dst.dev->mtu - 40, - ip_rt_min_advmss); + rt->u.dst.advmss = max(unsigned int, rt->u.dst.dev->mtu - 40, + ip_rt_min_advmss); if (rt->u.dst.advmss > 65535 - 40) rt->u.dst.advmss = 65535 - 40; diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index f8eff546c7ff..eb0f36fe9ac8 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -5,7 +5,7 @@ * * Implementation of the Transmission Control Protocol(TCP). * - * Version: $Id: tcp.c,v 1.205 2001/05/05 22:25:30 davem Exp $ + * Version: $Id: tcp.c,v 1.208 2001/08/13 18:56:12 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -852,7 +852,7 @@ 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(psize, PAGE_SIZE-offset); + size = min(unsigned int, psize, PAGE_SIZE-offset); if (tp->send_head==NULL || (copy = mss_now - skb->len) <= 0) { new_segment: @@ -2326,7 +2326,7 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char *optval, if(get_user(len,optlen)) return -EFAULT; - len = min(len, sizeof(int)); + len = min(unsigned int, len, sizeof(int)); if(len < 0) return -EINVAL; @@ -2421,7 +2421,7 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char *optval, info.tcpi_advmss = tp->advmss; info.tcpi_reordering = tp->reordering; - len = min(len, sizeof(info)); + len = min(unsigned int, len, sizeof(info)); if(put_user(len, optlen)) return -EFAULT; if(copy_to_user(optval, &info,len)) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 0c7e25da7c41..74563cde650a 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -5,7 +5,7 @@ * * Implementation of the Transmission Control Protocol(TCP). * - * Version: $Id: tcp_input.c,v 1.232 2001/05/24 22:32:49 davem Exp $ + * Version: $Id: tcp_input.c,v 1.235 2001/08/13 18:56:12 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -168,7 +168,7 @@ static void tcp_incr_quickack(struct tcp_opt *tp) if (quickacks==0) quickacks=2; if (quickacks > tp->ack.quick) - tp->ack.quick = min(quickacks, TCP_MAX_QUICKACKS); + tp->ack.quick = min(unsigned int, quickacks, TCP_MAX_QUICKACKS); } void tcp_enter_quickack_mode(struct tcp_opt *tp) @@ -198,7 +198,7 @@ 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(3*sndmem, sysctl_tcp_wmem[2]); + sk->sndbuf = min(int, 3*sndmem, sysctl_tcp_wmem[2]); } /* 2. Tuning advertised window (window_clamp, rcv_ssthresh) @@ -262,7 +262,7 @@ 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(tp->rcv_ssthresh + incr, tp->window_clamp); + tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh + incr, tp->window_clamp); tp->ack.quick |= 1; } } @@ -282,7 +282,7 @@ 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(4*rcvmem, sysctl_tcp_rmem[2]); + sk->rcvbuf = min(int, 4*rcvmem, sysctl_tcp_rmem[2]); } /* 4. Try to fixup all. It is made iimediately after connection enters @@ -304,16 +304,16 @@ 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(maxwin-(maxwin>>sysctl_tcp_app_win), 4*tp->advmss); + tp->window_clamp = max(u32, maxwin-(maxwin>>sysctl_tcp_app_win), 4*tp->advmss); } /* Force reservation of one segment. */ if (sysctl_tcp_app_win && tp->window_clamp > 2*tp->advmss && tp->window_clamp + tp->advmss > maxwin) - tp->window_clamp = max(2*tp->advmss, maxwin-tp->advmss); + tp->window_clamp = max(u32, 2*tp->advmss, maxwin-tp->advmss); - tp->rcv_ssthresh = min(tp->rcv_ssthresh, tp->window_clamp); + tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh, tp->window_clamp); tp->snd_cwnd_stamp = tcp_time_stamp; } @@ -338,7 +338,7 @@ 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(atomic_read(&sk->rmem_alloc), sysctl_tcp_rmem[2]); + sk->rcvbuf = min(int, atomic_read(&sk->rmem_alloc), sysctl_tcp_rmem[2]); } if (atomic_read(&sk->rmem_alloc) > sk->rcvbuf) { app_win += ofo_win; @@ -346,11 +346,11 @@ 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(app_win, 2*tp->advmss); + app_win = max(unsigned int, app_win, 2*tp->advmss); if (!ofo_win) - tp->window_clamp = min(tp->window_clamp, app_win); - tp->rcv_ssthresh = min(tp->window_clamp, 2*tp->advmss); + tp->window_clamp = min(u32, tp->window_clamp, app_win); + tp->rcv_ssthresh = min(u32, tp->window_clamp, 2*tp->advmss); } } @@ -472,7 +472,7 @@ 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(tp->mdev, TCP_RTO_MIN); + tp->mdev_max = tp->rttvar = max(u32, tp->mdev, TCP_RTO_MIN); tp->rtt_seq = tp->snd_nxt; } } @@ -575,7 +575,7 @@ 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(tp->snd_cwnd>>1, tp->snd_ssthresh); + dst->ssthresh = max(u32, tp->snd_cwnd>>1, tp->snd_ssthresh); if (!(dst->mxlock&(1<<RTAX_CWND))) dst->cwnd = (dst->cwnd + tp->snd_cwnd)>>1; } else { @@ -617,7 +617,7 @@ __u32 tcp_init_cwnd(struct tcp_opt *tp) else if (cwnd > tp->snd_ssthresh) cwnd = tp->snd_ssthresh; - return min(cwnd, tp->snd_cwnd_clamp); + return min(u32, cwnd, tp->snd_cwnd_clamp); } /* Initialize metrics on socket. */ @@ -668,7 +668,7 @@ 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(tp->mdev, TCP_RTO_MIN); + tp->mdev_max = tp->rttvar = max(u32, tp->mdev, TCP_RTO_MIN); } tcp_set_rto(tp); tcp_bound_rto(tp); @@ -693,7 +693,7 @@ reset: static void tcp_update_reordering(struct tcp_opt *tp, int metric, int ts) { if (metric > tp->reordering) { - tp->reordering = min(TCP_MAX_REORDERING, metric); + tp->reordering = min(unsigned int, TCP_MAX_REORDERING, metric); /* This exciting event is worth to be remembered. 8) */ if (ts) @@ -848,12 +848,12 @@ 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(fack_count, reord); + reord = min(int, fack_count, reord); } else { /* If it was in a hole, we detected reordering. */ if (fack_count < prior_fackets && !(sacked&TCPCB_SACKED_ACKED)) - reord = min(fack_count, reord); + reord = min(int, fack_count, reord); } /* Nothing to do; acked frame is about to be dropped. */ @@ -885,7 +885,7 @@ 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(fack_count, reord); + reord = min(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(fack_count, reord); + reord = min(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(tp->reordering, sysctl_tcp_reordering); + tp->reordering = min(unsigned int, tp->reordering, sysctl_tcp_reordering); tp->ca_state = TCP_CA_Loss; tp->high_seq = tp->snd_nxt; TCP_ECN_queue_cwr(tp); @@ -1177,7 +1177,7 @@ tcp_time_to_recover(struct sock *sk, struct tcp_opt *tp) * recovery more? */ if (tp->packets_out <= tp->reordering && - tp->sacked_out >= max(tp->packets_out/2, sysctl_tcp_reordering) && + tp->sacked_out >= max(u32, tp->packets_out/2, sysctl_tcp_reordering) && !tcp_may_send_now(sk, tp)) { /* We have nothing to send. This connection is limited * either by receiver window or by application. @@ -1194,7 +1194,9 @@ tcp_time_to_recover(struct sock *sk, struct tcp_opt *tp) */ static void tcp_check_reno_reordering(struct tcp_opt *tp, int addend) { - int holes = min(max(tp->lost_out, 1), tp->packets_out); + u32 holes = min(unsigned int, + max(unsigned int, tp->lost_out, 1), + tp->packets_out); if (tp->sacked_out + holes > tp->packets_out) { tp->sacked_out = tp->packets_out - holes; @@ -1289,7 +1291,7 @@ static 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(tp->snd_cwnd, + tp->snd_cwnd = min(u32, tp->snd_cwnd, tcp_packets_in_flight(tp)+tcp_max_burst(tp)); tp->snd_cwnd_stamp = tcp_time_stamp; } @@ -1306,7 +1308,7 @@ 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(tp->snd_cwnd, tcp_packets_in_flight(tp)+1); + tp->snd_cwnd = min(u32, tp->snd_cwnd, tcp_packets_in_flight(tp)+1); tp->snd_cwnd_stamp = tcp_time_stamp; } @@ -1338,13 +1340,15 @@ static void 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(tp->snd_cwnd, tp->snd_ssthresh<<1); + tp->snd_cwnd = max(unsigned int, + tp->snd_cwnd, tp->snd_ssthresh<<1); + if (undo && tp->prior_ssthresh > tp->snd_ssthresh) { tp->snd_ssthresh = tp->prior_ssthresh; TCP_ECN_withdraw_cwr(tp); } } else { - tp->snd_cwnd = max(tp->snd_cwnd, tp->snd_ssthresh); + tp->snd_cwnd = max(unsigned int, tp->snd_cwnd, tp->snd_ssthresh); } tcp_moderate_cwnd(tp); tp->snd_cwnd_stamp = tcp_time_stamp; @@ -1446,7 +1450,7 @@ static 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(tp->snd_cwnd, tp->snd_ssthresh); + tp->snd_cwnd = min(u32, tp->snd_cwnd, tp->snd_ssthresh); tp->snd_cwnd_stamp = tcp_time_stamp; } @@ -1832,7 +1836,7 @@ static void tcp_ack_probe(struct sock *sk) */ } else { tcp_reset_xmit_timer(sk, TCP_TIME_PROBE0, - min(tp->rto << tp->backoff, TCP_RTO_MAX)); + min(u32, tp->rto << tp->backoff, TCP_RTO_MAX)); } } @@ -2319,7 +2323,7 @@ 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(tp->num_sacks+1, 4-tp->tstamp_ok); + tp->eff_sacks = min(unsigned int, tp->num_sacks+1, 4-tp->tstamp_ok); } } @@ -2372,7 +2376,7 @@ static void tcp_sack_maybe_coalesce(struct tcp_opt *tp) * Decrease num_sacks. */ tp->num_sacks--; - tp->eff_sacks = min(tp->num_sacks+tp->dsack, 4-tp->tstamp_ok); + tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok); for(i=this_sack; i < tp->num_sacks; i++) sp[i] = sp[i+1]; continue; @@ -2434,7 +2438,7 @@ new_sack: sp->start_seq = seq; sp->end_seq = end_seq; tp->num_sacks++; - tp->eff_sacks = min(tp->num_sacks+tp->dsack, 4-tp->tstamp_ok); + tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok); } /* RCV.NXT advances, some SACKs should be eaten. */ @@ -2471,7 +2475,7 @@ static void tcp_sack_remove(struct tcp_opt *tp) } if (num_sacks != tp->num_sacks) { tp->num_sacks = num_sacks; - tp->eff_sacks = min(tp->num_sacks+tp->dsack, 4-tp->tstamp_ok); + tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok); } } @@ -2537,7 +2541,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) if (tp->dsack) { tp->dsack = 0; - tp->eff_sacks = min(tp->num_sacks, 4-tp->tstamp_ok); + tp->eff_sacks = min(unsigned int, tp->num_sacks, 4-tp->tstamp_ok); } /* Queue data for delivery to the user. @@ -2554,7 +2558,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) tp->ucopy.len && sk->lock.users && !tp->urg_data) { - int chunk = min(skb->len, tp->ucopy.len); + int chunk = min(unsigned int, skb->len, tp->ucopy.len); __set_current_state(TASK_RUNNING); @@ -2803,7 +2807,7 @@ tcp_collapse(struct sock *sk, struct sk_buff *head, if (offset < 0) BUG(); if (size > 0) { - size = min(copy, size); + size = min(int, copy, size); if (skb_copy_bits(skb, offset, skb_put(nskb, size), size)) BUG(); TCP_SKB_CB(nskb)->end_seq += size; @@ -2882,7 +2886,7 @@ 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(tp->rcv_ssthresh, 4*tp->advmss); + tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh, 4*tp->advmss); tcp_collapse_ofo_queue(sk); tcp_collapse(sk, sk->receive_queue.next, @@ -2937,7 +2941,7 @@ 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(tp->snd_cwnd_used, 2); + u32 win_used = max(u32, tp->snd_cwnd_used, 2); if (win_used < tp->snd_cwnd) { tp->snd_ssthresh = tcp_current_ssthresh(tp); tp->snd_cwnd = (tp->snd_cwnd+win_used)>>1; @@ -2963,10 +2967,10 @@ 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(tp->snd_cwnd, tp->reordering+1); + demanded = max(unsigned int, tp->snd_cwnd, tp->reordering+1); sndmem *= 2*demanded; if (sndmem > sk->sndbuf) - sk->sndbuf = min(sndmem, sysctl_tcp_wmem[2]); + sk->sndbuf = min(int, sndmem, sysctl_tcp_wmem[2]); tp->snd_cwnd_stamp = tcp_time_stamp; } @@ -3516,7 +3520,7 @@ 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(tp->window_clamp,65535); + tp->window_clamp = min(u32, tp->window_clamp, 65535); } if (tp->saw_tstamp) { diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 97fb6c8ca97b..701834143a98 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -5,7 +5,7 @@ * * Implementation of the Transmission Control Protocol(TCP). * - * Version: $Id: tcp_minisocks.c,v 1.11 2001/08/03 14:27:25 davem Exp $ + * Version: $Id: tcp_minisocks.c,v 1.12 2001/08/13 18:56:13 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -766,7 +766,7 @@ 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(newtp->window_clamp,65535); + newtp->window_clamp = min(u32, newtp->window_clamp, 65535); } newtp->snd_wnd = ntohs(skb->h.th->window) << newtp->snd_wscale; newtp->max_window = newtp->snd_wnd; diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 91e4a7b848b2..f4ec7c94a400 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -5,7 +5,7 @@ * * Implementation of the Transmission Control Protocol(TCP). * - * Version: $Id: tcp_output.c,v 1.137 2001/06/29 21:11:28 davem Exp $ + * Version: $Id: tcp_output.c,v 1.140 2001/08/13 18:56:12 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -105,11 +105,11 @@ static void tcp_cwnd_restart(struct tcp_opt *tp) u32 cwnd = tp->snd_cwnd; tp->snd_ssthresh = tcp_current_ssthresh(tp); - restart_cwnd = min(restart_cwnd, cwnd); + restart_cwnd = min(u32, restart_cwnd, cwnd); while ((delta -= tp->rto) > 0 && cwnd > restart_cwnd) cwnd >>= 1; - tp->snd_cwnd = max(cwnd, restart_cwnd); + tp->snd_cwnd = max(u32, cwnd, restart_cwnd); tp->snd_cwnd_stamp = tcp_time_stamp; tp->snd_cwnd_used = 0; } @@ -526,7 +526,7 @@ 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((tp->max_window>>1), 68 - tp->tcp_header_len); + mss_now = max(u32, (tp->max_window>>1), 68 - tp->tcp_header_len); /* And store cached results */ tp->pmtu_cookie = pmtu; @@ -651,7 +651,7 @@ u32 __tcp_select_window(struct sock *sk) */ int mss = tp->ack.rcv_mss; int free_space = tcp_space(sk); - int full_space = min(tp->window_clamp, tcp_full_space(sk)); + int full_space = min(unsigned int, tp->window_clamp, tcp_full_space(sk)); int window; if (mss > full_space) @@ -661,7 +661,7 @@ u32 __tcp_select_window(struct sock *sk) tp->ack.quick = 0; if (tcp_memory_pressure) - tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4*tp->advmss); + tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh, 4*tp->advmss); if (free_space < mss) return 0; @@ -817,7 +817,7 @@ 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(sk->wmem_queued+(sk->wmem_queued>>2),sk->sndbuf)) + if (atomic_read(&sk->wmem_alloc) > min(int, sk->wmem_queued+(sk->wmem_queued>>2),sk->sndbuf)) return -EAGAIN; /* If receiver has shrunk his window, and skb is out of @@ -1264,13 +1264,13 @@ void tcp_send_delayed_ack(struct sock *sk) * directly. */ if (tp->srtt) { - int rtt = max(tp->srtt>>3, TCP_DELACK_MIN); + int rtt = max(unsigned int, tp->srtt>>3, TCP_DELACK_MIN); if (rtt < max_ato) max_ato = rtt; } - ato = min(ato, max_ato); + ato = min(int, ato, max_ato); } /* Stay within the limit we were given */ @@ -1386,7 +1386,7 @@ 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(seg_size, mss); + seg_size = min(int, seg_size, mss); TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH; if (tcp_fragment(sk, skb, seg_size)) return -1; @@ -1429,7 +1429,7 @@ void tcp_send_probe0(struct sock *sk) tp->backoff++; tp->probes_out++; tcp_reset_xmit_timer (sk, TCP_TIME_PROBE0, - min(tp->rto << tp->backoff, TCP_RTO_MAX)); + min(u32, tp->rto << tp->backoff, TCP_RTO_MAX)); } else { /* If packet was not sent due to local congestion, * do not backoff and do not remember probes_out. @@ -1440,6 +1440,6 @@ void tcp_send_probe0(struct sock *sk) if (!tp->probes_out) tp->probes_out=1; tcp_reset_xmit_timer (sk, TCP_TIME_PROBE0, - min(tp->rto << tp->backoff, TCP_RESOURCE_PROBE_INTERVAL)); + min(unsigned int, tp->rto << tp->backoff, TCP_RESOURCE_PROBE_INTERVAL)); } } diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 1ee26fde4cb1..421bfef2e427 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -5,7 +5,7 @@ * * Implementation of the Transmission Control Protocol(TCP). * - * Version: $Id: tcp_timer.c,v 1.83 2001/03/07 22:00:57 davem Exp $ + * Version: $Id: tcp_timer.c,v 1.85 2001/08/13 18:56:12 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -248,7 +248,7 @@ 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(tp->ack.ato<<1, tp->rto); + tp->ack.ato = min(u32, tp->ack.ato << 1, tp->rto); } else { /* Delayed ACK missed: leave pingpong mode and * deflate ATO. @@ -381,7 +381,7 @@ static void tcp_retransmit_timer(struct sock *sk) if (!tp->retransmits) tp->retransmits=1; tcp_reset_xmit_timer(sk, TCP_TIME_RETRANS, - min(tp->rto, TCP_RESOURCE_PROBE_INTERVAL)); + min(u32, tp->rto, TCP_RESOURCE_PROBE_INTERVAL)); goto out; } @@ -404,7 +404,7 @@ static void tcp_retransmit_timer(struct sock *sk) tp->retransmits++; out_reset_timer: - tp->rto = min(tp->rto << 1, TCP_RTO_MAX); + tp->rto = min(u32, tp->rto << 1, TCP_RTO_MAX); tcp_reset_xmit_timer(sk, TCP_TIME_RETRANS, tp->rto); if (tp->retransmits > sysctl_tcp_retries1) __sk_dst_reset(sk); @@ -517,7 +517,8 @@ static void tcp_synack_timer(struct sock *sk) if (req->retrans++ == 0) lopt->qlen_young--; - timeo = min((TCP_TIMEOUT_INIT << req->retrans), + timeo = min(unsigned long, + (TCP_TIMEOUT_INIT << req->retrans), TCP_RTO_MAX); req->expires = now + timeo; reqp = &req->dl_next; diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index fc1c9f392909..fbc0e6bd77ed 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -5,7 +5,7 @@ * Authors: * Pedro Roque <roque@di.fc.ul.pt> * - * $Id: icmp.c,v 1.32 2001/06/10 09:20:07 davem Exp $ + * $Id: icmp.c,v 1.35 2001/08/13 18:56:13 davem Exp $ * * Based on net/ipv4/icmp.c * @@ -365,7 +365,7 @@ 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(len, IPV6_MIN_MTU - sizeof(struct ipv6hdr)); + len = min(unsigned int, len, IPV6_MIN_MTU - sizeof(struct ipv6hdr)); if (len < 0) { printk(KERN_DEBUG "icmp: len problem\n"); diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 2332f754928a..81b5341eeb81 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -7,7 +7,7 @@ * * Based on linux/net/ipv4/ip_sockglue.c * - * $Id: ipv6_sockglue.c,v 1.36 2001/02/26 05:59:07 davem Exp $ + * $Id: ipv6_sockglue.c,v 1.39 2001/08/13 18:56:13 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -535,7 +535,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, char *optval, return -EINVAL; #endif } - len=min(sizeof(int),len); + len = min(unsigned int, sizeof(int), len); if(put_user(len, optlen)) return -EFAULT; if(copy_to_user(optval,&val,len)) diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index d9970663ae42..3d243fabd47a 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c @@ -5,7 +5,7 @@ * Authors: * Pedro Roque <roque@di.fc.ul.pt> * - * $Id: mcast.c,v 1.37 2001/04/25 20:46:34 davem Exp $ + * $Id: mcast.c,v 1.38 2001/08/15 07:36:31 davem Exp $ * * Based on linux/ipv4/igmp.c and linux/ipv4/ip_sockglue.c * @@ -90,7 +90,6 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr) mc_lst->next = NULL; memcpy(&mc_lst->addr, addr, sizeof(struct in6_addr)); - mc_lst->ifindex = ifindex; if (ifindex == 0) { struct rt6_info *rt; @@ -108,6 +107,8 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr) return -ENODEV; } + mc_lst->ifindex = dev->ifindex; + /* * now add/increase the group membership on the device */ diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index e4257e9f3b15..2812b12b2066 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -846,7 +846,8 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, } } - rd_len = min(IPV6_MIN_MTU-sizeof(struct ipv6hdr)-len, skb->len + 8); + rd_len = min(unsigned int, + IPV6_MIN_MTU-sizeof(struct ipv6hdr)-len, skb->len + 8); rd_len &= ~0x7; len += rd_len; diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index bee18b4e13fc..cb144410d15e 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -7,7 +7,7 @@ * * Adapted from linux/net/ipv4/raw.c * - * $Id: raw.c,v 1.46 2001/06/05 11:36:55 davem Exp $ + * $Id: raw.c,v 1.49 2001/08/13 18:56:13 davem Exp $ * * Fixes: * Hideaki YOSHIFUJI : sin6_scope_id support @@ -699,7 +699,7 @@ static int rawv6_getsockopt(struct sock *sk, int level, int optname, return -ENOPROTOOPT; } - len=min(sizeof(int),len); + len = min(unsigned int, sizeof(int), len); if (put_user(len, optlen)) return -EFAULT; diff --git a/net/ipv6/route.c b/net/ipv6/route.c index f6e0e4787bb7..2448e18f9098 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -5,7 +5,7 @@ * Authors: * Pedro Roque <roque@di.fc.ul.pt> * - * $Id: route.c,v 1.51 2001/05/03 07:02:47 davem Exp $ + * $Id: route.c,v 1.54 2001/08/13 18:56:13 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -785,7 +785,7 @@ int ip6_route_add(struct in6_rtmsg *rtmsg) install_route: rt->u.dst.pmtu = ipv6_get_mtu(dev); - rt->u.dst.advmss = max(rt->u.dst.pmtu - 60, ip6_rt_min_advmss); + rt->u.dst.advmss = max(unsigned int, rt->u.dst.pmtu - 60, ip6_rt_min_advmss); /* Maximal non-jumbo IPv6 payload is 65535 and corresponding MSS is 65535 - tcp_header_size. 65535 is also valid and means: "any MSS, rely only on pmtu discovery" @@ -944,7 +944,7 @@ 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(nrt->u.dst.pmtu - 60, ip6_rt_min_advmss); + nrt->u.dst.advmss = max(unsigned int, nrt->u.dst.pmtu - 60, ip6_rt_min_advmss); if (rt->u.dst.advmss > 65535-20) rt->u.dst.advmss = 65535; nrt->rt6i_hoplimit = ipv6_get_hoplimit(neigh->dev); @@ -1199,7 +1199,7 @@ 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(rt->u.dst.pmtu - 60, ip6_rt_min_advmss); + rt->u.dst.advmss = max(unsigned int, rt->u.dst.pmtu - 60, ip6_rt_min_advmss); if (rt->u.dst.advmss > 65535-20) rt->u.dst.advmss = 65535; rt->rt6i_hoplimit = ipv6_get_hoplimit(rt->rt6i_dev); @@ -1390,7 +1390,7 @@ 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(arg->mtu - 60, ip6_rt_min_advmss); + rt->u.dst.advmss = max(unsigned int, arg->mtu - 60, ip6_rt_min_advmss); if (rt->u.dst.advmss > 65535-20) rt->u.dst.advmss = 65535; return 0; diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index 669cdbb06c3f..36df373aa1bb 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c @@ -1890,7 +1890,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname, if (get_user(len, optlen)) goto out; - len = min(len, sizeof(int)); + len = min(unsigned int, len, sizeof(int)); ret = -EINVAL; if(len < 0) goto out; diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 49d2110d8f85..e42a9abf228b 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c @@ -1400,7 +1400,7 @@ static int irda_recvmsg_stream(struct socket *sock, struct msghdr *msg, continue; } - chunk = min(skb->len, size); + chunk = min(unsigned int, skb->len, size); if (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) { skb_queue_head(&sk->receive_queue, skb); if (copied == 0) diff --git a/net/khttpd/datasending.c b/net/khttpd/datasending.c index 5726dca3297e..b0f58dca0006 100644 --- a/net/khttpd/datasending.c +++ b/net/khttpd/datasending.c @@ -105,8 +105,8 @@ int DataSending(const int CPUNR) Space = sock_wspace(CurrentRequest->sock->sk); - ReadSize = min(4*4096,CurrentRequest->FileLength - CurrentRequest->BytesSent); - ReadSize = min(ReadSize , Space ); + ReadSize = min(int, 4 * 4096, CurrentRequest->FileLength - CurrentRequest->BytesSent); + ReadSize = min(int, ReadSize, Space); if (ReadSize>0) { diff --git a/net/khttpd/prototypes.h b/net/khttpd/prototypes.h index 78e891d8e7f2..c47830886897 100644 --- a/net/khttpd/prototypes.h +++ b/net/khttpd/prototypes.h @@ -19,17 +19,6 @@ #define CONFIG_KHTTPD_NUMCPU 16 /* Maximum number of threads */ -/* the TCP/IP stack defines a __BROKEN__ set of min/max functions !! */ -/* So we better define our own. */ - -/* Broken means: working on unsigned data only, which is not acceptable - for kHTTPd and probably a lot of other functions. */ - -#undef min -#undef max -#define min(a,b) ( (a) < (b) ? (a) : (b) ) -#define max(a,b) ( (a) > (b) ? (a) : (b) ) - #ifdef OOPSTRACE #define EnterFunction(x) printk("Enter: %s, %s line %i\n",x,__FILE__,__LINE__) #define LeaveFunction(x) printk("Leave: %s, %s line %i\n",x,__FILE__,__LINE__) diff --git a/net/khttpd/rfc.c b/net/khttpd/rfc.c index a9f2491781e9..6070ef563406 100644 --- a/net/khttpd/rfc.c +++ b/net/khttpd/rfc.c @@ -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(255,tmp-Buffer+PrefixLen); + Head->FileNameLength = min(unsigned int, 255, tmp - Buffer + PrefixLen); - strncat(Head->FileName,Buffer,min(255-PrefixLen,tmp-Buffer)); + strncat(Head->FileName,Buffer,min(unsigned int, 255 - PrefixLen, tmp - Buffer)); Buffer=EOL+1; #ifdef BENCHMARK @@ -341,7 +341,7 @@ void ParseHeader(char *Buffer,const int length, struct http_request *Head) { Buffer+=19; - strncpy(Head->IMS,Buffer,min(127,EOL-Buffer-1)); + strncpy(Head->IMS,Buffer,min(unsigned int, 127,EOL-Buffer-1)); Buffer=EOL+1; continue; @@ -351,7 +351,7 @@ void ParseHeader(char *Buffer,const int length, struct http_request *Head) { Buffer+=12; - strncpy(Head->Agent,Buffer,min(127,EOL-Buffer-1)); + strncpy(Head->Agent,Buffer,min(unsigned int, 127,EOL-Buffer-1)); Buffer=EOL+1; continue; @@ -362,7 +362,7 @@ void ParseHeader(char *Buffer,const int length, struct http_request *Head) { Buffer+=6; - strncpy(Head->Host,Buffer,min(127,EOL-Buffer-1)); + strncpy(Head->Host,Buffer,min(unsigned int, 127,EOL-Buffer-1)); Buffer=EOL+1; continue; diff --git a/net/khttpd/waitheaders.c b/net/khttpd/waitheaders.c index 2c24f3744c83..1d49822b7400 100644 --- a/net/khttpd/waitheaders.c +++ b/net/khttpd/waitheaders.c @@ -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(Request->Time,CurrentTime_i),Request->TimeS); + time_Unix2RFC(min(unsigned int, Request->Time,CurrentTime_i),Request->TimeS); /* The min() is required by rfc1945, section 10.10: It is not allowed to send a filetime in the future */ diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index c6df629dc6e7..2b94267d85dd 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -435,7 +435,7 @@ static int nr_getsockopt(struct socket *sock, int level, int optname, return -ENOPROTOOPT; } - len = min(len, sizeof(int)); + len = min(unsigned int, len, sizeof(int)); if (put_user(len, optlen)) return -EFAULT; diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index b9220b31a3ed..dd554124a876 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -508,7 +508,7 @@ static int rose_getsockopt(struct socket *sock, int level, int optname, return -ENOPROTOOPT; } - len = min(len, sizeof(int)); + len = min(unsigned int, len, sizeof(int)); if (put_user(len, optlen)) return -EFAULT; diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 7b5248e74de7..7c8aea21c5c9 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -227,7 +227,7 @@ tbf_dequeue(struct Qdisc* sch) } if (!netif_queue_stopped(sch->dev)) { - long delay = PSCHED_US2JIFFIE(max(-toks, -ptoks)); + long delay = PSCHED_US2JIFFIE(max(long, -toks, -ptoks)); if (delay == 0) delay = 1; diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 9cda62023cf0..6f079e3bd2d8 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -81,42 +81,61 @@ rpcauth_init_credcache(struct rpc_auth *auth) auth->au_nextgc = jiffies + (auth->au_expire >> 1); } +/* + * Destroy an unreferenced credential + */ static inline void -rpcauth_crdestroy(struct rpc_auth *auth, struct rpc_cred *cred) +rpcauth_crdestroy(struct rpc_cred *cred) { #ifdef RPC_DEBUG if (cred->cr_magic != RPCAUTH_CRED_MAGIC) BUG(); cred->cr_magic = 0; + if (atomic_read(&cred->cr_count) || cred->cr_auth) + BUG(); #endif - if (auth->au_ops->crdestroy) - auth->au_ops->crdestroy(cred); - else - rpc_free(cred); + cred->cr_ops->crdestroy(cred); +} + +/* + * Destroy a list of credentials + */ +static inline +void rpcauth_destroy_credlist(struct rpc_cred *head) +{ + struct rpc_cred *cred; + + while ((cred = head) != NULL) { + head = cred->cr_next; + rpcauth_crdestroy(cred); + } } /* - * Clear the RPC credential cache + * Clear the RPC credential cache, and delete those credentials + * that are not referenced. */ void rpcauth_free_credcache(struct rpc_auth *auth) { - struct rpc_cred **q, *cred; - void (*destroy)(struct rpc_cred *); + struct rpc_cred **q, *cred, *free = NULL; int i; - if (!(destroy = auth->au_ops->crdestroy)) - destroy = (void (*)(struct rpc_cred *)) rpc_free; - spin_lock(&rpc_credcache_lock); for (i = 0; i < RPC_CREDCACHE_NR; i++) { q = &auth->au_credcache[i]; while ((cred = *q) != NULL) { *q = cred->cr_next; - destroy(cred); + cred->cr_auth = NULL; + if (atomic_read(&cred->cr_count) == 0) { + cred->cr_next = free; + free = cred; + } else + cred->cr_next = NULL; } } spin_unlock(&rpc_credcache_lock); + rpcauth_destroy_credlist(free); } /* @@ -133,9 +152,10 @@ rpcauth_gc_credcache(struct rpc_auth *auth) for (i = 0; i < RPC_CREDCACHE_NR; i++) { q = &auth->au_credcache[i]; while ((cred = *q) != NULL) { - if (!cred->cr_count && + if (!atomic_read(&cred->cr_count) && time_before(cred->cr_expire, jiffies)) { *q = cred->cr_next; + cred->cr_auth = NULL; cred->cr_next = free; free = cred; continue; @@ -144,10 +164,7 @@ rpcauth_gc_credcache(struct rpc_auth *auth) } } spin_unlock(&rpc_credcache_lock); - while ((cred = free) != NULL) { - free = cred->cr_next; - rpcauth_crdestroy(auth, cred); - } + rpcauth_destroy_credlist(free); auth->au_nextgc = jiffies + auth->au_expire; } @@ -163,8 +180,8 @@ rpcauth_insert_credcache(struct rpc_auth *auth, struct rpc_cred *cred) spin_lock(&rpc_credcache_lock); cred->cr_next = auth->au_credcache[nr]; auth->au_credcache[nr] = cred; - cred->cr_count++; - cred->cr_expire = jiffies + auth->au_expire; + cred->cr_auth = auth; + get_rpccred(cred); spin_unlock(&rpc_credcache_lock); } @@ -187,7 +204,7 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, int taskflags) q = &auth->au_credcache[nr]; while ((cred = *q) != NULL) { if (!(cred->cr_flags & RPCAUTH_CRED_DEAD) && - auth->au_ops->crmatch(cred, taskflags)) { + cred->cr_ops->crmatch(cred, taskflags)) { *q = cred->cr_next; break; } @@ -213,23 +230,23 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, int taskflags) * Remove cred handle from cache */ static void -rpcauth_remove_credcache(struct rpc_auth *auth, struct rpc_cred *cred) +rpcauth_remove_credcache(struct rpc_cred *cred) { + struct rpc_auth *auth = cred->cr_auth; struct rpc_cred **q, *cr; int nr; nr = (cred->cr_uid & RPC_CREDCACHE_MASK); - spin_lock(&rpc_credcache_lock); q = &auth->au_credcache[nr]; while ((cr = *q) != NULL) { if (cred == cr) { *q = cred->cr_next; cred->cr_next = NULL; + cred->cr_auth = NULL; break; } q = &cred->cr_next; } - spin_unlock(&rpc_credcache_lock); } struct rpc_cred * @@ -258,7 +275,7 @@ rpcauth_matchcred(struct rpc_auth *auth, struct rpc_cred *cred, int taskflags) { dprintk("RPC: matching %s cred %d\n", auth->au_ops->au_name, taskflags); - return auth->au_ops->crmatch(cred, taskflags); + return cred->cr_ops->crmatch(cred, taskflags); } void @@ -266,26 +283,25 @@ rpcauth_holdcred(struct rpc_task *task) { dprintk("RPC: %4d holding %s cred %p\n", task->tk_pid, task->tk_auth->au_ops->au_name, task->tk_msg.rpc_cred); - if (task->tk_msg.rpc_cred) { - spin_lock(&rpc_credcache_lock); - task->tk_msg.rpc_cred->cr_count++; - task->tk_msg.rpc_cred->cr_expire = jiffies + task->tk_auth->au_expire; - spin_unlock(&rpc_credcache_lock); - } + if (task->tk_msg.rpc_cred) + get_rpccred(task->tk_msg.rpc_cred); } void -rpcauth_releasecred(struct rpc_auth *auth, struct rpc_cred *cred) +put_rpccred(struct rpc_cred *cred) { - spin_lock(&rpc_credcache_lock); - if (cred != NULL && cred->cr_count > 0) { - if (!--cred->cr_count && (cred->cr_flags & RPCAUTH_CRED_DEAD)) { - spin_unlock(&rpc_credcache_lock); - rpcauth_remove_credcache(auth, cred); - rpcauth_crdestroy(auth, cred); - return; - } + if (!atomic_dec_and_lock(&cred->cr_count, &rpc_credcache_lock)) + return; + + if (cred->cr_auth && cred->cr_flags & RPCAUTH_CRED_DEAD) + rpcauth_remove_credcache(cred); + + if (!cred->cr_auth) { + spin_unlock(&rpc_credcache_lock); + rpcauth_crdestroy(cred); + return; } + cred->cr_expire = jiffies + cred->cr_auth->au_expire; spin_unlock(&rpc_credcache_lock); } @@ -298,7 +314,7 @@ rpcauth_unbindcred(struct rpc_task *task) dprintk("RPC: %4d releasing %s cred %p\n", task->tk_pid, auth->au_ops->au_name, cred); - rpcauth_releasecred(auth, cred); + put_rpccred(cred); task->tk_msg.rpc_cred = NULL; } @@ -306,10 +322,11 @@ u32 * rpcauth_marshcred(struct rpc_task *task, u32 *p) { struct rpc_auth *auth = task->tk_auth; + struct rpc_cred *cred = task->tk_msg.rpc_cred; dprintk("RPC: %4d marshaling %s cred %p\n", - task->tk_pid, auth->au_ops->au_name, task->tk_msg.rpc_cred); - return auth->au_ops->crmarshal(task, p, + task->tk_pid, auth->au_ops->au_name, cred); + return cred->cr_ops->crmarshal(task, p, task->tk_flags & RPC_CALL_REALUID); } @@ -317,20 +334,22 @@ u32 * rpcauth_checkverf(struct rpc_task *task, u32 *p) { struct rpc_auth *auth = task->tk_auth; + struct rpc_cred *cred = task->tk_msg.rpc_cred; dprintk("RPC: %4d validating %s cred %p\n", - task->tk_pid, auth->au_ops->au_name, task->tk_msg.rpc_cred); - return auth->au_ops->crvalidate(task, p); + task->tk_pid, auth->au_ops->au_name, cred); + return cred->cr_ops->crvalidate(task, p); } int rpcauth_refreshcred(struct rpc_task *task) { struct rpc_auth *auth = task->tk_auth; + struct rpc_cred *cred = task->tk_msg.rpc_cred; dprintk("RPC: %4d refreshing %s cred %p\n", - task->tk_pid, auth->au_ops->au_name, task->tk_msg.rpc_cred); - task->tk_status = auth->au_ops->crrefresh(task); + task->tk_pid, auth->au_ops->au_name, cred); + task->tk_status = cred->cr_ops->crrefresh(task); return task->tk_status; } diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c index 0e9fddb2807b..17e8370a0f15 100644 --- a/net/sunrpc/auth_null.c +++ b/net/sunrpc/auth_null.c @@ -17,6 +17,8 @@ # define RPCDBG_FACILITY RPCDBG_AUTH #endif +static struct rpc_credops null_credops; + static struct rpc_auth * nul_create(struct rpc_clnt *clnt) { @@ -52,9 +54,10 @@ nul_create_cred(int flags) if (!(cred = (struct rpc_cred *) rpc_allocate(flags, sizeof(*cred)))) return NULL; - cred->cr_count = 0; + atomic_set(&cred->cr_count, 0); cred->cr_flags = RPCAUTH_CRED_UPTODATE; cred->cr_uid = current->uid; + cred->cr_ops = &null_credops; return cred; } @@ -124,7 +127,11 @@ struct rpc_authops authnull_ops = { #endif nul_create, nul_destroy, - nul_create_cred, + nul_create_cred +}; + +static +struct rpc_credops null_credops = { nul_destroy_cred, nul_match, nul_marshal, diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index dae3067b55f2..cb0804f2ef19 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c @@ -33,6 +33,8 @@ struct unx_cred { # define RPCDBG_FACILITY RPCDBG_AUTH #endif +static struct rpc_credops unix_credops; + static struct rpc_auth * unx_create(struct rpc_clnt *clnt) { @@ -71,7 +73,7 @@ unx_create_cred(int flags) if (!(cred = (struct unx_cred *) rpc_allocate(flags, sizeof(*cred)))) return NULL; - cred->uc_count = 0; + atomic_set(&cred->uc_count, 0); cred->uc_flags = RPCAUTH_CRED_UPTODATE; if (flags & RPC_TASK_ROOTCREDS) { cred->uc_uid = cred->uc_fsuid = 0; @@ -91,6 +93,7 @@ unx_create_cred(int flags) if (i < NFS_NGROUPS) cred->uc_gids[i] = NOGROUP; } + cred->uc_base.cr_ops = &unix_credops; return (struct rpc_cred *) cred; } @@ -106,7 +109,7 @@ authunix_fake_cred(struct rpc_task *task, uid_t uid, gid_t gid) if (!(cred = (struct unx_cred *) rpc_malloc(task, sizeof(*cred)))) return NULL; - cred->uc_count = 1; + atomic_set(&cred->uc_count, 1); cred->uc_flags = RPCAUTH_CRED_DEAD|RPCAUTH_CRED_UPTODATE; cred->uc_uid = uid; cred->uc_gid = gid; @@ -236,7 +239,11 @@ struct rpc_authops authunix_ops = { #endif unx_create, unx_destroy, - unx_create_cred, + unx_create_cred +}; + +static +struct rpc_credops unix_credops = { unx_destroy_cred, unx_match, unx_marshal, diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index 1c5fd37406c4..369358b73e20 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c @@ -65,7 +65,7 @@ EXPORT_SYMBOL(rpcauth_insert_credcache); EXPORT_SYMBOL(rpcauth_lookupcred); EXPORT_SYMBOL(rpcauth_bindcred); EXPORT_SYMBOL(rpcauth_matchcred); -EXPORT_SYMBOL(rpcauth_releasecred); +EXPORT_SYMBOL(put_rpccred); /* RPC server stuff */ EXPORT_SYMBOL(svc_create); diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 67f430b9dcc3..39e9afa70a60 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -84,11 +84,6 @@ spinlock_t xprt_lock = SPIN_LOCK_UNLOCKED; # define RPCDBG_FACILITY RPCDBG_XPRT #endif -#ifndef MAX -# define MAX(a, b) ((a) > (b)? (a) : (b)) -# define MIN(a, b) ((a) < (b)? (a) : (b)) -#endif - /* * Local functions */ @@ -749,7 +744,7 @@ tcp_read_xid(struct rpc_xprt *xprt, int avail) if (xprt->tcp_copied >= sizeof(xprt->tcp_xid) || !avail) goto done; - want = MIN(sizeof(xprt->tcp_xid) - xprt->tcp_copied, avail); + want = min(unsigned int, sizeof(xprt->tcp_xid) - xprt->tcp_copied, avail); do { dprintk("RPC: reading xid (%d bytes)\n", want); riov.iov_base = ((u8*) &xprt->tcp_xid) + xprt->tcp_copied; @@ -776,7 +771,7 @@ 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(req->rq_rlen - xprt->tcp_copied, avail); + want = min(unsigned int, req->rq_rlen - xprt->tcp_copied, avail); do { dprintk("RPC: %4d TCP receiving %d bytes\n", req->rq_task->tk_pid, want); @@ -810,7 +805,7 @@ tcp_read_discard(struct rpc_xprt *xprt, int avail) int want, result = 0; while (avail) { - want = MIN(avail, sizeof(dummy)); + want = min(unsigned int, avail, sizeof(dummy)); riov.iov_base = dummy; riov.iov_len = want; dprintk("RPC: TCP skipping %d bytes\n", want); @@ -1072,7 +1067,7 @@ udp_write_space(struct sock *sk) /* Wait until we have enough socket memory */ - if (sock_wspace(sk) < min(sk->sndbuf,XPRT_MIN_WRITE_SPACE)) + if (sock_wspace(sk) < min(int, sk->sndbuf,XPRT_MIN_WRITE_SPACE)) return; if (!xprt_test_and_set_wspace(xprt)) { diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 1147480aa3a5..728548457cd1 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -8,7 +8,7 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * - * Version: $Id: af_unix.c,v 1.118 2001/07/18 07:52:37 davem Exp $ + * Version: $Id: af_unix.c,v 1.121 2001/08/13 18:56:13 davem Exp $ * * Fixes: * Linus Torvalds : Assorted bug cures. @@ -111,8 +111,6 @@ #include <asm/checksum.h> -#define min(a,b) (((a)<(b))?(a):(b)) - int sysctl_unix_max_dgram_qlen = 10; unix_socket *unix_socket_table[UNIX_HASH_SIZE+1]; @@ -1338,7 +1336,7 @@ 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(size, skb_tailroom(skb)); + size = min(int, size, skb_tailroom(skb)); memcpy(UNIXCREDS(skb), &scm->creds, sizeof(struct ucred)); if (scm->fp) @@ -1570,7 +1568,7 @@ static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, int size sunaddr = NULL; } - chunk = min(skb->len, size); + chunk = min(unsigned int, skb->len, size); if (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) { skb_queue_head(&sk->receive_queue, skb); if (copied == 0) diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c index 74fb480baddf..b58338f52f06 100644 --- a/net/wanrouter/wanmain.c +++ b/net/wanrouter/wanmain.c @@ -139,17 +139,6 @@ static void dbg_kfree(void * v, int line) { /* - * Defines and Macros - */ - -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef max -#define max(a,b) (((a)>(b))?(a):(b)) -#endif - -/* * Function Prototypes */ diff --git a/net/wanrouter/wanproc.c b/net/wanrouter/wanproc.c index 9dd10ce27fef..92156ea3086a 100644 --- a/net/wanrouter/wanproc.c +++ b/net/wanrouter/wanproc.c @@ -46,13 +46,6 @@ /****** Defines and Macros **************************************************/ -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef max -#define max(a,b) (((a)>(b))?(a):(b)) -#endif - #define PROC_BUFSZ 4000 /* buffer size for printing proc info */ #define PROT_DECODE(prot) ((prot == WANCONFIG_FR) ? " FR" :\ @@ -266,7 +259,7 @@ typedef struct wan_stat_entry pos = dent->get_info(page, dent->data, 0, 0); offs = file->f_pos; if (offs < pos) { - len = min(pos - offs, count); + len = min(unsigned int, pos - offs, count); if (copy_to_user(buf, (page + offs), len)) { kfree(page); return -EFAULT; @@ -812,7 +805,7 @@ typedef struct wan_stat_entry pos = dent->get_info(page, dent->data, 0, 0, 0); offs = file->f_pos; if (offs < pos) { - len = min(pos - offs, count); + len = min(unsigned int, pos - offs, count); if (copy_to_user(buf, (page + offs), len)) { kfree(page); return -EFAULT; @@ -848,7 +841,7 @@ typedef struct wan_stat_entry pos = dent->get_info(page, dent->data, 0, 0, 0); offs = file->f_pos; if (offs < pos) { - len = min(pos - offs, count); + len = min(unsigned int, pos - offs, count); memcpy_tofs((void*)buf, (void*)(page + offs), len); file->f_pos += len; } diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index a4c425392dd2..95f1037061ec 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -407,7 +407,7 @@ static int x25_getsockopt(struct socket *sock, int level, int optname, return -ENOPROTOOPT; } - len = min(len, sizeof(int)); + len = min(unsigned int, len, sizeof(int)); if (len < 0) return -EINVAL; |
