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.
VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 9
-EXTRAVERSION =-pre4
+EXTRAVERSION =
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
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 */
0xff, "ETRAX 100LX",
data, wLength);
if (len > 0) {
- OK (min (leni, len));
+ OK(min(int, leni, len));
} else
stat = -EPIPE;
}
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);
#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 */
#ifdef CONFIG_X86_PAE
EXPORT_SYMBOL(empty_zero_page);
#endif
+
+#ifdef CONFIG_HAVE_DEC_LOCK
+EXPORT_SYMBOL(atomic_dec_and_lock);
+#endif
-/* $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)
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 */
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)
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)
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)
-/* $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)
# 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
# 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
-/* $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.
*
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
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
-/* $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.
*
/* 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
-/* $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)
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:
-/* $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)
* 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;
-/* $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)
{
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;
}
-/* $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)
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;
-/* $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)
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));
/* 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);
-/* $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)
-/* $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)
-/* $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)
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
-/* $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)
}
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,
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;
/*
* 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) &
/*
* 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) &
* 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 =
#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
*/
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.
*/
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);
}
#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 ": "
/* 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 */
/* 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 */
#define PAUSE ;
#endif
-#define cy_min(a,b) (((a)<(b))?(a):(b))
-
/*
* Include section
*/
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
}
#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],
#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); \
{ \
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); \
int __init dz_init(void)
{
- int i, flags;
+ int i;
+ unsigned long flags;
struct dz_serial *info;
/* Setup base handler, and timer table. */
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");
#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;
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;
}
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 */
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;
}
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;
#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
** 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);
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.
{
int unit = 0;
int i = 0;
- int flags;
+ unsigned long flags;
spin_lock_irqsave(&io_request_lock, flags);
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)
{
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;
{
u32 id = (u32)file->private_data;
struct i2o_cfg_info *p1, *p2;
- unsigned int flags;
+ unsigned long flags;
lock_kernel();
p1 = p2 = NULL;
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();
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);
"IBM-DTLA-305040",
"IBM-DTLA-305030",
"IBM-DTLA-305020",
+ "IC35L010AVER07-0",
+ "IC35L020AVER07-0",
+ "IC35L030AVER07-0",
+ "IC35L040AVER07-0",
+ "IC35L060AVER07-0",
"WDC AC310200R",
NULL
};
"IBM-DTLA-305040",
"IBM-DTLA-305030",
"IBM-DTLA-305020",
+ "IC35L010AVER07-0",
+ "IC35L020AVER07-0",
+ "IC35L030AVER07-0",
+ "IC35L040AVER07-0",
+ "IC35L060AVER07-0",
"WDC AC310200R",
NULL
};
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 {
static
unsigned long ide_cdrom_capacity (ide_drive_t *drive)
{
- unsigned capacity;
+ unsigned long capacity;
if (cdrom_read_capacity(drive, &capacity, NULL))
return 0;
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. */
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. */
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");
{
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) {
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();
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);
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);
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
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];
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");
{
struct sbp2scsi_host_info *hi;
int i;
- unsigned int flags;
+ unsigned long flags;
SBP2_DEBUG("sbp2: sbp2_remove_host");
{
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);
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;
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);
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;
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) {
/* 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);
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 */
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))
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;
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);
return x;
}
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
#define CLEAR(a,n) {\
int ci;\
for(ci=(n)-1;ci >=0;ci--)\
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])];
}
#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
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);
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);
* 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)
{
*/
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);
}
I596_RBD *rbdp;
int count;
int i, len, amt;
-# define mymin(A,B) ( (A) < (B) ? (A) : (B) )
/*
* Determine 0th priv and dev structure pointers
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;
/* --------------------------------------------------------------------- */
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-
-/* --------------------------------------------------------------------- */
-
#define KISS_VERBOSE
/* --------------------------------------------------------------------- */
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)
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))
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;
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));
/* --------------------------------------------------------------------- */
-#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
/* --------------------------------------------------------------------- */
-#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
/* --------------------------------------------------------------------- */
-#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
#define PARAM_HARDWARE 6
#define PARAM_RETURN 255
-/* --------------------------------------------------------------------- */
-
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-
/* --------------------------------------------------------------------- */
/*
* the CRC routines are stolen from WAMPES
/* --------------------------------------------------------------------- */
-#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[];
if (buffer_length >= len - offset) {
*eof = 1;
}
- return (min(buffer_length, len - offset));
+ return (min(int, buffer_length, len - offset));
}
-/* $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)
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);
-/* $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.
}
/* 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));
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;
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;
}
if (count >= len - off) {
*eof = 1;
}
- return(min(count, len - off));
+ return min(int, count, len - off);
}
/* Called on echo comx >boardtype */
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,
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;
}
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);
}
*start = page + off;
if (count >= len - off) *eof = 1;
- return ( min(count, len - off) );
+ return min(int, count, len - off);
}
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;
}
*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,
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,
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;
if (count >= len - off) {
*eof = 1;
}
- return( min(count, len - off) );
+ return min(int, count, len - off);
}
if (count >= len - off) {
*eof = 1;
}
- return( min(count, len - off) );
+ return min(int, count, len - off);
}
#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)
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;
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)
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))
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 );
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
#define __initdata
#endif
-#define min( x, y ) ( (x) < (y) ? (x) : (y) )
-
#endif
/* 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;
}
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;
}
/* 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
/* 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));
* 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++) {
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;
*/
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;
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;
}
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;
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
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 */
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)
/* 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;
}
#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!!! */
// 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
* 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;
}
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;
-/* airport.c 0.05
+/* airport.c 0.06f
*
* A driver for "Hermes" chipset based Apple Airport wireless
* card.
#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;
struct dldwd_priv priv;
} dldwd_card_t;
-static char *version = "airport.c 0.05 (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
-
/*
* Function prototypes
*/
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);
{
struct device_node* airport_node;
- printk(KERN_INFO "%s\n", version);
+ printk(KERN_DEBUG "%s\n", version);
MOD_INC_USE_COUNT;
* 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>
#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 */
static int hermes_issue_cmd(hermes_t *hw, uint16_t cmd, uint16_t param0);
-/*
- * Internal inline functions
- */
-
/*
* Internal functions
*/
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);
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)) {
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
static int __init init_hermes(void)
{
- printk(KERN_INFO "%s\n", version);
+ printk(KERN_DEBUG "%s\n", version);
return 0;
}
#define HERMES_STATUS_CMDCODE (0x003f)
/*
- * OFFSET refister bitmasks
+ * OFFSET register bitmasks
*/
#define HERMES_OFFSET_BUSY (0x8000)
#define HERMES_OFFSET_ERR (0x4000)
-/* 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/
* 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
* 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
#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
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
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
priv->port_type = 4;
else
priv->port_type = 1;
+ priv->port_type = priv->ibss_port;
priv->allow_ibss = 1;
}
break;
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) {
/* 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) {
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
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]);
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);
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);
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),
}
#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;
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));
} 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;
err = dldwd_proc_init();
- printk(KERN_INFO "%s\n", version);
+ printk(KERN_DEBUG "%s\n", version);
return 0;
}
#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;
/*====================================================================*/
-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
-/* 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/
#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' */
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
*/
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 */
/*====================================================================*/
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)
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) {
#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
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);
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,
#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
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);
-/* $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)
-/* $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)
-/* $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)
send_data(KBD_CMD_ENABLE);
}
+int pcikbd_rate(struct kbd_repeat *rep)
+{
+ return -EIO;
+}
+
static int pcikbd_wait_for_input(void)
{
int status, data;
-/* $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)
-/* $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)
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 */
}
}
}
- 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);
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) {
#define FALSE 0
#endif
-#define min(a,b) ((a<b)?(a):(b))
-
#define R_LIMIT 0x20000
#define MAXISA 4
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);
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);
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;
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);
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);
ips_scb_t *scb;
IPS_STATUS cstatus;
int intrstatus;
- u32 cpu_flags;
+ unsigned long cpu_flags;
METHOD_TRACE("ips_intr", 2);
ips_scb_t *scb;
IPS_STATUS cstatus;
int intrstatus;
- u32 cpu_flags;
+ unsigned long cpu_flags;
METHOD_TRACE("ips_intr_morpheus", 2);
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);
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);
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);
/****************************************************************************/
static void
ips_freescb(ips_ha_t *ha, ips_scb_t *scb) {
- u32 cpu_flags;
+ unsigned long cpu_flags;
METHOD_TRACE("ips_freescb", 1);
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);
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);
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);
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);
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);
/****************************************************************************/
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);
/****************************************************************************/
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);
#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
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:
#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 */
/* 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,
/* 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);
#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))
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;
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;
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;
}
} 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;
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;
*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;
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;
*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;
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;
*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;
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;
*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;
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++))
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++))
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++))
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) {
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++))
frameLeft >>= 2;
if (stereo)
userCount >>= 1;
- used = count = min(userCount, frameLeft);
+ used = count = min(unsigned long, userCount, frameLeft);
while (count > 0) {
u_char data;
frameLeft >>= 2;
if (stereo)
userCount >>= 1;
- used = count = min(userCount, frameLeft);
+ used = count = min(unsigned long, userCount, frameLeft);
while (count > 0) {
u_char data;
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) {
frameLeft >>= 2;
userCount >>= (stereo? 2: 1);
- used = count = min(userCount, frameLeft);
+ used = count = min(unsigned long, userCount, frameLeft);
while (count > 0) {
int data;
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++)
\
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; \
} 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; \
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)++)) \
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)++)) \
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) {
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++))
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) {
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++))
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;
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++))
if ((bytestocopy >= wiinst->buffer.fragment_size)
|| (bytestocopy >= count)) {
- bytestocopy = min(bytestocopy, count);
+ bytestocopy = min(u32, bytestocopy, count);
emu10k1_wavein_xferdata(wiinst, (u8 *) buffer, &bytestocopy);
if ((bytestocopy >= woinst->buffer.fragment_size)
|| (bytestocopy >= count)) {
- bytestocopy = min(bytestocopy, count);
+ bytestocopy = min(u32, bytestocopy, count);
emu10k1_waveout_xferdata(woinst, (u8 *) buffer, &bytestocopy);
u32 sizetocopy, sizetocopy_now, start;
unsigned long flags;
- sizetocopy = min(buffer->size, *size);
+ sizetocopy = min(u32, buffer->size, *size);
*size = sizetocopy;
if (!sizetocopy)
u32 sizetocopy, sizetocopy_now, start;
unsigned long flags;
- sizetocopy = min(buffer->size, *size);
+ sizetocopy = min(u32, buffer->size, *size);
*size = sizetocopy;
if (!sizetocopy)
#define FLAGS_AVAILABLE 0x0001
#define FLAGS_READY 0x0002
-#define min(x,y) ((x) < (y)) ? (x) : (y)
-
struct memhandle
{
dma_addr_t dma_handle;
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);
}
}
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)
#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
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 */
// 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
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;
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;
#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 {
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;
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;
#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 {
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 */
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 */
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:
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;
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,
data, wLength);
if (len > 0) {
data_buf = data;
- OK (min (leni, len));
+ OK(min(int, leni, len));
}
// else fallthrough
default:
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);
}
// 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;
#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
{
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 */
uhci->io_addr, "UHCI",
data, wLength);
if (len > 0) {
- OK (min (leni, len));
+ OK(min(int, leni, len));
} else
stat = -EPIPE;
}
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);
#define RH_REQ_ERR -1
#define RH_NACK 0x00
-#define min(a,b) (((a)<(b))?(a):(b))
-
#endif
((((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)
/**************************************************/
-#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 */
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
*/
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)
*/
run_task_queue(&tq_disk);
- current->policy |= SCHED_YIELD;
- __set_current_state(TASK_RUNNING);
- schedule();
+ free_more_memory();
goto try_again;
}
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 */
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;
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;
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);
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;
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;
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;
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;
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;
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 */
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);
#include <linux/stat.h>
#include <linux/fat_cvf.h>
+#include "msbuffer.h"
+
#if 0
# define PRINTK(x) printk x
#else
void * buf,
const char * name,
int name_len,
- off_t offset,
+ loff_t offset,
ino_t ino,
unsigned int d_type)
{
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) {
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"));
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
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"));
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)
"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);
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],
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;
}
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);
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;
}
#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);
#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;
/* 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,
}
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;
#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
*/
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,
#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) {
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;
/* 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);
#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;
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);
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,
mmap: nfs_file_mmap,
open: nfs_open,
flush: nfs_file_flush,
- release: nfs_file_release,
+ release: nfs_release,
fsync: nfs_fsync,
lock: nfs_lock,
};
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)
{
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 *);
delete_inode: nfs_delete_inode,
put_super: nfs_put_super,
statfs: nfs_statfs,
+ clear_inode: nfs_clear_inode,
umount_begin: nfs_umount_begin,
};
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)
{
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;
return nfs_revalidate_inode(NFS_SERVER(inode), inode);
}
+/*
+ * 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
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;
}
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;
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);
}
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),
io_error:
kunmap(page);
+ if (cred)
+ put_rpccred(cred);
return written? written : result;
}
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:
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;
/* 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 */
if (end > rqend)
req->wb_bytes = end - req->wb_offset;
- nfs_unlock_request(req);
-
return req;
}
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.
"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) {
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);
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;
}
__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)
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;
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;
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");
* 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,
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",
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 -
#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")
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);
__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++);
#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)
{
"%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;
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);
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);
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);
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;
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);
*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 (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))
*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)
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;
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;
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;
* 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
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)
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,
--- /dev/null
+#ifndef __ASM_SPARC_HW_IRQ_H
+#define __ASM_SPARC_HW_IRQ_H
+
+/* Dummy include. */
+
+#endif
--- /dev/null
+#ifndef __ASM_SPARC64_HW_IRQ_H
+#define __ASM_SPARC64_HW_IRQ_H
+
+/* Dummy include. */
+
+#endif
-/* $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)
#ifdef __KERNEL__
+#include <linux/kernel.h>
+#include <linux/kd.h>
+
#define KEYBOARD_IRQ 1
#define DISABLE_KBD_DURING_INTERRUPTS 0
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];
#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
-/* $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
#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)
{
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) \
-/* $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)
/* 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;
-/* $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)
#include <asm/asi.h>
#include <asm/mmu_context.h>
#include <asm/system.h>
+#include <asm/page.h>
#ifndef __ASSEMBLY__
* 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))
/* 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) ? \
#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
#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.
((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
#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
}
}
-#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)
*/
#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)
#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) \
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;
struct inode *hash_next,
*hash_prev;
unsigned long nextscan;
+
+ /* Credentials for shared mmap */
+ struct rpc_cred *mm_cred;
};
/*
#include <linux/config.h>
#include <linux/sunrpc/sched.h>
+#include <asm/atomic.h>
+
/* size of the nodename buffer */
#define UNX_MAXNODENAME 32
*/
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 */
void (*destroy)(struct rpc_auth *);
struct rpc_cred * (*crcreate)(int);
+};
+
+struct rpc_credops {
void (*crdestroy)(struct rpc_cred *);
int (*crmatch)(struct rpc_cred *, int);
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);
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 */
* 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
#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)
#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);
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.
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)
*/
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.
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)
{
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;
{
/* 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.
* 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 */
(*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)--;
}
*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)
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);
}
}
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)
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
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();
{
unsigned long vaddr;
unsigned long nr;
+ int need_wakeup;
spin_lock(&kmap_lock);
vaddr = (unsigned long) page->virtual;
* 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
{
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,
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;
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. *
/* 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
}
/* 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 */
return -EFAULT;
valptr = (void *) &val;
- length = min(maxlen, sizeof(int));
+ length = min(unsigned int, maxlen, sizeof(int));
switch (optname) {
case AX25_WINDOW:
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';
* 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
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);
* 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
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;
}
* 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
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,
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;
{
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;
{
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;
{
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;
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))
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. */
*
* 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
*
#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
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))
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);
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))
* 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.
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))
}
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);
* 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.
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))
*
* 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>
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;
}
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;
*
* 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>
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:
if(get_user(len,optlen))
return -EFAULT;
- len = min(len, sizeof(int));
+ len = min(unsigned int, len, sizeof(int));
if(len < 0)
return -EINVAL;
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))
*
* 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>
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)
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)
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;
}
}
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
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;
}
!(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;
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);
}
}
/* 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;
}
}
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 {
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. */
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);
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)
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. */
*/
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;
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
}
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);
* 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.
*/
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;
*/
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;
}
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;
}
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;
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;
}
*/
} 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));
}
}
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);
}
}
* 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;
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. */
}
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);
}
}
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.
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);
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;
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,
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;
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;
}
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) {
*
* 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>
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;
*
* 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>
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;
}
/* 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;
*/
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)
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;
/* 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
* 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 */
*/
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;
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.
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));
}
}
*
* 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>
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.
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;
}
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);
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;
* 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
*
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");
*
* 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
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))
* 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
*
mc_lst->next = NULL;
memcpy(&mc_lst->addr, addr, sizeof(struct in6_addr));
- mc_lst->ifindex = ifindex;
if (ifindex == 0) {
struct rt6_info *rt;
return -ENODEV;
}
+ mc_lst->ifindex = dev->ifindex;
+
/*
* now add/increase the group membership on the device
*/
}
}
- 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;
*
* 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
return -ENOPROTOOPT;
}
- len=min(sizeof(int),len);
+ len = min(unsigned int, sizeof(int), len);
if (put_user(len, optlen))
return -EFAULT;
* 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
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"
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);
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);
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;
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;
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)
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)
{
#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__)
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
{
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;
{
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;
{
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;
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 */
return -ENOPROTOOPT;
}
- len = min(len, sizeof(int));
+ len = min(unsigned int, len, sizeof(int));
if (put_user(len, optlen))
return -EFAULT;
return -ENOPROTOOPT;
}
- len = min(len, sizeof(int));
+ len = min(unsigned int, len, sizeof(int));
if (put_user(len, optlen))
return -EFAULT;
}
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;
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);
}
/*
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;
}
}
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;
}
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);
}
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;
}
* 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 *
{
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
{
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);
}
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;
}
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);
}
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;
}
# define RPCDBG_FACILITY RPCDBG_AUTH
#endif
+static struct rpc_credops null_credops;
+
static struct rpc_auth *
nul_create(struct rpc_clnt *clnt)
{
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;
}
#endif
nul_create,
nul_destroy,
- nul_create_cred,
+ nul_create_cred
+};
+
+static
+struct rpc_credops null_credops = {
nul_destroy_cred,
nul_match,
nul_marshal,
# define RPCDBG_FACILITY RPCDBG_AUTH
#endif
+static struct rpc_credops unix_credops;
+
static struct rpc_auth *
unx_create(struct rpc_clnt *clnt)
{
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;
if (i < NFS_NGROUPS)
cred->uc_gids[i] = NOGROUP;
}
+ cred->uc_base.cr_ops = &unix_credops;
return (struct rpc_cred *) cred;
}
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;
#endif
unx_create,
unx_destroy,
- unx_create_cred,
+ unx_create_cred
+};
+
+static
+struct rpc_credops unix_credops = {
unx_destroy_cred,
unx_match,
unx_marshal,
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);
# 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
*/
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;
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);
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);
/* 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)) {
* 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.
#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];
* 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)
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)
*****************************************************************************/
-/*
- * 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
*/
/****** 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" :\
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;
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;
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;
}
return -ENOPROTOOPT;
}
- len = min(len, sizeof(int));
+ len = min(unsigned int, len, sizeof(int));
if (len < 0)
return -EINVAL;