merged min/max changes from KERNEL_2_4 branch
This commit is contained in:
parent
e80660afb5
commit
a87ac24dee
|
@ -431,7 +431,9 @@ void DivasOut(ADAPTER * a)
|
|||
i = this->XCurrent;
|
||||
X = PTR_X(a,this);
|
||||
while(i<this->XNum && length<270) {
|
||||
clength = MIN((word)(270-length),X[i].PLength-this->XOffset);
|
||||
clength = (word)(270-length);
|
||||
if (clength > X[i].PLength-this->XOffset)
|
||||
clength = X[i].PLength-this->XOffset;
|
||||
a->ram_out_buffer(a,
|
||||
&ReqOut->XBuffer.P[length],
|
||||
PTR_P(a,this,&X[i].P[this->XOffset]),
|
||||
|
@ -837,8 +839,9 @@ byte isdn_ind(ADAPTER * a,
|
|||
this->ROffset = 0;
|
||||
this->RCurrent++;
|
||||
}
|
||||
clength = MIN(a->ram_inw(a, &RBuffer->length)-offset,
|
||||
R[this->RCurrent].PLength-this->ROffset);
|
||||
clength = a->ram_inw(a, &RBuffer->length)-offset;
|
||||
if (clength > R[this->RCurrent].PLength-this->ROffset)
|
||||
clength = R[this->RCurrent].PLength-this->ROffset;
|
||||
if(R[this->RCurrent].P) {
|
||||
a->ram_in_buffer(a,
|
||||
&RBuffer->P[offset],
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
#include "eicon.h"
|
||||
#include "sys.h"
|
||||
#include <stdarg.h>
|
||||
#undef MAX
|
||||
#undef MIN
|
||||
|
||||
#include "divas.h"
|
||||
#include "divalog.h"
|
||||
|
|
|
@ -29,12 +29,6 @@
|
|||
#define byte unsigned char
|
||||
#define word unsigned short
|
||||
#define dword unsigned long
|
||||
#if !defined(MIN)
|
||||
#define MIN(a,b) ((a)>(b) ? (b) : (a))
|
||||
#endif
|
||||
#if !defined(MAX)
|
||||
#define MAX(a,b) ((a)>(b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* buffer definition */
|
||||
|
|
|
@ -54,15 +54,6 @@ typedef volatile dword vdword;
|
|||
#define NULL ((void *) 0)
|
||||
#endif
|
||||
|
||||
/* MIN and MAX */
|
||||
|
||||
#if !defined(MIN)
|
||||
#define MIN(a,b) ((a)>(b) ? (b) : (a))
|
||||
#endif
|
||||
#if !defined(MAX)
|
||||
#define MAX(a,b) ((a)>(b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* Return the dimension of an array */
|
||||
|
||||
#if !defined(DIM)
|
||||
|
|
|
@ -14,10 +14,6 @@
|
|||
#define RS_ISR_PASS_LIMIT 256
|
||||
#define BASE_BAUD ( 1843200 / 16 )
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
//#define SERIAL_DEBUG_OPEN 1
|
||||
//#define SERIAL_DEBUG_INTR 1
|
||||
//#define SERIAL_DEBUG_FLOW 1
|
||||
|
@ -257,7 +253,7 @@ inline int
|
|||
write_modem(struct BCState *bcs) {
|
||||
int ret=0;
|
||||
struct IsdnCardState *cs = bcs->cs;
|
||||
int count, len, fp, buflen;
|
||||
int count, len, fp;
|
||||
long flags;
|
||||
|
||||
if (!bcs->tx_skb)
|
||||
|
@ -266,12 +262,14 @@ write_modem(struct BCState *bcs) {
|
|||
return 0;
|
||||
save_flags(flags);
|
||||
cli();
|
||||
buflen = MAX_MODEM_BUF - cs->hw.elsa.transcnt;
|
||||
len = MIN(buflen, bcs->tx_skb->len);
|
||||
len = bcs->tx_skb->len;
|
||||
if (len > MAX_MODEM_BUF - cs->hw.elsa.transcnt)
|
||||
len = MAX_MODEM_BUF - cs->hw.elsa.transcnt;
|
||||
fp = cs->hw.elsa.transcnt + cs->hw.elsa.transp;
|
||||
fp &= (MAX_MODEM_BUF -1);
|
||||
count = MIN(len, MAX_MODEM_BUF - fp);
|
||||
if (count < len) {
|
||||
count = len;
|
||||
if (count > MAX_MODEM_BUF - fp) {
|
||||
count = MAX_MODEM_BUF - fp;
|
||||
memcpy(cs->hw.elsa.transbuf + fp, bcs->tx_skb->data, count);
|
||||
skb_pull(bcs->tx_skb, count);
|
||||
cs->hw.elsa.transcnt += count;
|
||||
|
@ -540,8 +538,9 @@ modem_write_cmd(struct IsdnCardState *cs, u_char *buf, int len) {
|
|||
}
|
||||
fp = cs->hw.elsa.transcnt + cs->hw.elsa.transp;
|
||||
fp &= (MAX_MODEM_BUF -1);
|
||||
count = MIN(len, MAX_MODEM_BUF - fp);
|
||||
if (count < len) {
|
||||
count = len;
|
||||
if (count > MAX_MODEM_BUF - fp) {
|
||||
count = MAX_MODEM_BUF - fp;
|
||||
memcpy(cs->hw.elsa.transbuf + fp, msg, count);
|
||||
cs->hw.elsa.transcnt += count;
|
||||
msg += count;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#define DBG_LOADFIRM 0
|
||||
#define DUMP_MBOXFRAME 2
|
||||
|
||||
#define MIN(a,b) ((a<b)?a:b)
|
||||
|
||||
#define DLE 0x10
|
||||
#define ETX 0x03
|
||||
|
||||
|
@ -272,7 +270,9 @@ isar_load_firmware(struct IsdnCardState *cs, u_char *buf)
|
|||
ret = 1;goto reterror;
|
||||
}
|
||||
while (left>0) {
|
||||
noc = MIN(126, left);
|
||||
noc = left;
|
||||
if (noc > 126)
|
||||
noc = 126;
|
||||
nom = 2*noc;
|
||||
mp = msg;
|
||||
*mp++ = sadr / 256;
|
||||
|
|
|
@ -930,7 +930,9 @@ icn_loadproto(u_char * buffer, icn_card * card)
|
|||
restore_flags(flags);
|
||||
while (left) {
|
||||
if (sbfree) { /* If there is a free buffer... */
|
||||
cnt = MIN(256, left);
|
||||
cnt = left;
|
||||
if (cnt > 256)
|
||||
cnt = 256;
|
||||
if (copy_from_user(codebuf, p, cnt)) {
|
||||
icn_maprelease_channel(card, 0);
|
||||
return -EFAULT;
|
||||
|
@ -1029,7 +1031,6 @@ static int
|
|||
icn_writecmd(const u_char * buf, int len, int user, icn_card * card)
|
||||
{
|
||||
int mch = card->secondhalf ? 2 : 0;
|
||||
int avail;
|
||||
int pp;
|
||||
int i;
|
||||
int count;
|
||||
|
@ -1046,8 +1047,9 @@ icn_writecmd(const u_char * buf, int len, int user, icn_card * card)
|
|||
ocount = 1;
|
||||
xcount = loop = 0;
|
||||
while (len) {
|
||||
avail = cmd_free;
|
||||
count = MIN(avail, len);
|
||||
count = cmd_free;
|
||||
if (count > len)
|
||||
count = len;
|
||||
if (user)
|
||||
copy_from_user(msg, buf, count);
|
||||
else
|
||||
|
|
|
@ -285,8 +285,5 @@ MODULE_PARM_DESC(icn_id2, "ID-String of first card, second S0 (4B only)");
|
|||
|
||||
#define CID (card->interface.id)
|
||||
|
||||
#define MIN(a,b) ((a<b)?a:b)
|
||||
#define MAX(a,b) ((a>b)?a:b)
|
||||
|
||||
#endif /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
|
||||
#endif /* icn_h */
|
||||
|
|
|
@ -607,7 +607,9 @@ isdn_audio_calc_dtmf(modem_info * info, unsigned char *buf, int len, int fmt)
|
|||
int c;
|
||||
|
||||
while (len) {
|
||||
c = MIN(len, (DTMF_NPOINTS - s->idx));
|
||||
c = DTMF_NPOINTS - s->idx;
|
||||
if (c > len)
|
||||
c = len;
|
||||
if (c <= 0)
|
||||
break;
|
||||
for (i = 0; i < c; i++) {
|
||||
|
|
|
@ -800,7 +800,6 @@ isdn_getnum(char **p)
|
|||
int
|
||||
isdn_readbchan(int di, int channel, u_char * buf, u_char * fp, int len, wait_queue_head_t *sleep)
|
||||
{
|
||||
int left;
|
||||
int count;
|
||||
int count_pull;
|
||||
int count_put;
|
||||
|
@ -816,10 +815,11 @@ isdn_readbchan(int di, int channel, u_char * buf, u_char * fp, int len, wait_que
|
|||
else
|
||||
return 0;
|
||||
}
|
||||
left = MIN(len, dev->drv[di]->rcvcount[channel]);
|
||||
if (len > dev->drv[di]->rcvcount[channel])
|
||||
len = dev->drv[di]->rcvcount[channel];
|
||||
cp = buf;
|
||||
count = 0;
|
||||
while (left) {
|
||||
while (len) {
|
||||
if (!(skb = skb_peek(&dev->drv[di]->rpqueue[channel])))
|
||||
break;
|
||||
#ifdef CONFIG_ISDN_AUDIO
|
||||
|
@ -832,8 +832,8 @@ isdn_readbchan(int di, int channel, u_char * buf, u_char * fp, int len, wait_que
|
|||
|
||||
dflag = 0;
|
||||
count_pull = count_put = 0;
|
||||
while ((count_pull < skb->len) && (left > 0)) {
|
||||
left--;
|
||||
while ((count_pull < skb->len) && (len > 0)) {
|
||||
len--;
|
||||
if (dev->drv[di]->DLEflag & DLEmask) {
|
||||
*cp++ = DLE;
|
||||
dev->drv[di]->DLEflag &= ~DLEmask;
|
||||
|
@ -854,14 +854,14 @@ isdn_readbchan(int di, int channel, u_char * buf, u_char * fp, int len, wait_que
|
|||
#endif
|
||||
/* No DLE's in buff, so simply copy it */
|
||||
dflag = 1;
|
||||
if ((count_pull = skb->len) > left) {
|
||||
count_pull = left;
|
||||
if ((count_pull = skb->len) > len) {
|
||||
count_pull = len;
|
||||
dflag = 0;
|
||||
}
|
||||
count_put = count_pull;
|
||||
memcpy(cp, skb->data, count_put);
|
||||
cp += count_put;
|
||||
left -= count_put;
|
||||
len -= count_put;
|
||||
#ifdef CONFIG_ISDN_AUDIO
|
||||
}
|
||||
#endif
|
||||
|
@ -1209,12 +1209,15 @@ isdn_read(struct file *file, char *buf, size_t count, loff_t * off)
|
|||
#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT
|
||||
if(drvidx || (len = isdn_dw_abc_lcr_readstat(buf,count)) < 1) {
|
||||
#endif
|
||||
if (dev->drv[drvidx]->interface->readstat)
|
||||
if (dev->drv[drvidx]->interface->readstat) {
|
||||
if (count > dev->drv[drvidx]->stavail)
|
||||
count = dev->drv[drvidx]->stavail;
|
||||
len = dev->drv[drvidx]->interface->
|
||||
readstat(buf, MIN(count, dev->drv[drvidx]->stavail),
|
||||
1, drvidx, isdn_minor2chan(minor));
|
||||
else
|
||||
readstat(buf, count, 1, drvidx,
|
||||
isdn_minor2chan(minor));
|
||||
} else {
|
||||
len = 0;
|
||||
}
|
||||
#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1187,9 +1187,11 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co
|
|||
/* See isdn_tty_senddown() */
|
||||
atomic_inc(&info->xmit_lock);
|
||||
while (1) {
|
||||
c = MIN(count, info->xmit_size - info->xmit_count);
|
||||
if (info->isdn_driver >= 0)
|
||||
c = MIN(c, dev->drv[info->isdn_driver]->maxbufsize);
|
||||
c = count;
|
||||
if (c > info->xmit_size - info->xmit_count)
|
||||
c = info->xmit_size - info->xmit_count;
|
||||
if (info->isdn_driver >= 0 && c > dev->drv[info->isdn_driver]->maxbufsize)
|
||||
c = dev->drv[info->isdn_driver]->maxbufsize;
|
||||
if (c <= 0)
|
||||
break;
|
||||
if ((info->online > 1)
|
||||
|
|
|
@ -985,10 +985,12 @@ isdnloop_writecmd(const u_char * buf, int len, int user, isdnloop_card * card)
|
|||
isdn_ctrl cmd;
|
||||
|
||||
while (len) {
|
||||
int count = MIN(255, len);
|
||||
int count = len;
|
||||
u_char *p;
|
||||
u_char msg[0x100];
|
||||
|
||||
if (count > 255)
|
||||
count = 255;
|
||||
if (user)
|
||||
copy_from_user(msg, buf, count);
|
||||
else
|
||||
|
|
|
@ -128,8 +128,6 @@ MODULE_PARM_DESC(isdnloop_id, "ID-String of first card");
|
|||
/* Utility-Macros */
|
||||
|
||||
#define CID (card->interface.id)
|
||||
#define MIN(a,b) ((a<b)?a:b)
|
||||
#define MAX(a,b) ((a>b)?a:b)
|
||||
|
||||
#endif /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
|
||||
#endif /* isdnloop_h */
|
||||
|
|
|
@ -176,7 +176,6 @@ pcbit_transmit(struct pcbit_dev *dev)
|
|||
struct frame_buf *frame = NULL;
|
||||
unsigned char unacked;
|
||||
int flen; /* fragment frame length including all headers */
|
||||
int totlen; /* non-fragmented frame length */
|
||||
int free;
|
||||
int count,
|
||||
cp_len;
|
||||
|
@ -213,11 +212,12 @@ pcbit_transmit(struct pcbit_dev *dev)
|
|||
ulong msg;
|
||||
|
||||
if (frame->skb)
|
||||
totlen = FRAME_HDR_LEN + PREHDR_LEN + frame->skb->len;
|
||||
flen = FRAME_HDR_LEN + PREHDR_LEN + frame->skb->len;
|
||||
else
|
||||
totlen = FRAME_HDR_LEN + PREHDR_LEN;
|
||||
flen = FRAME_HDR_LEN + PREHDR_LEN;
|
||||
|
||||
flen = MIN(totlen, free);
|
||||
if (flen > free)
|
||||
flen = free;
|
||||
|
||||
msg = frame->msg;
|
||||
|
||||
|
@ -259,9 +259,10 @@ pcbit_transmit(struct pcbit_dev *dev)
|
|||
} else {
|
||||
/* Type 1 frame */
|
||||
|
||||
totlen = 2 + (frame->skb->len - frame->copied);
|
||||
flen = 2 + (frame->skb->len - frame->copied);
|
||||
|
||||
flen = MIN(totlen, free);
|
||||
if (flen > free)
|
||||
flen = free;
|
||||
|
||||
/* TT */
|
||||
tt = ((ushort) (flen - 2)) | 0x8000U; /* Type 1 */
|
||||
|
@ -271,8 +272,9 @@ pcbit_transmit(struct pcbit_dev *dev)
|
|||
}
|
||||
|
||||
if (frame->skb) {
|
||||
cp_len = MIN(frame->skb->len - frame->copied,
|
||||
flen - count);
|
||||
cp_len = frame->skb->len - frame->copied;
|
||||
if (cp_len > flen - count)
|
||||
cp_len = flen - count;
|
||||
|
||||
memcpy_topcbit(dev, frame->skb->data + frame->copied,
|
||||
cp_len);
|
||||
|
|
|
@ -121,8 +121,6 @@ struct frame_buf {
|
|||
struct frame_buf * next;
|
||||
};
|
||||
|
||||
#define MIN(a,b) ((a<b)?a:b)
|
||||
|
||||
extern int pcbit_l2_write(struct pcbit_dev * dev, ulong msg, ushort refnum,
|
||||
struct sk_buff *skb, unsigned short hdr_len);
|
||||
|
||||
|
|
|
@ -825,9 +825,6 @@ extern int dwabc_isdn_get_net_free_channel(isdn_net_local *);
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* Utility-Macros */
|
||||
#define MIN(a,b) ((a<b)?a:b)
|
||||
#define MAX(a,b) ((a>b)?a:b)
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* __ISDN_H__ */
|
||||
|
|
Loading…
Reference in New Issue