Use common macro to check message length.
This commit is contained in:
parent
5e6dd3ae03
commit
064be15283
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mesh.c,v 1.12 2001/07/22 11:29:46 wiz Exp $ */
|
||||
/* $NetBSD: mesh.c,v 1.13 2001/11/04 12:03:41 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 Tsubai Masanari.
|
||||
|
@ -665,10 +665,6 @@ mesh_status(sc, scb)
|
|||
sc->sc_nextstate = MESH_MSGIN;
|
||||
}
|
||||
|
||||
#define IS1BYTEMSG(m) (((m) != 1 && (m) < 0x20) || (m) & 0x80)
|
||||
#define IS2BYTEMSG(m) (((m) & 0xf0) == 0x20)
|
||||
#define ISEXTMSG(m) ((m) == 1)
|
||||
|
||||
void
|
||||
mesh_msgin(sc, scb)
|
||||
struct mesh_softc *sc;
|
||||
|
@ -686,11 +682,11 @@ mesh_msgin(sc, scb)
|
|||
|
||||
sc->sc_imsg[sc->sc_imsglen++] = mesh_read_reg(sc, MESH_FIFO);
|
||||
|
||||
if (sc->sc_imsglen == 1 && IS1BYTEMSG(sc->sc_imsg[0]))
|
||||
if (sc->sc_imsglen == 1 && MSG_IS1BYTE(sc->sc_imsg[0]))
|
||||
goto gotit;
|
||||
if (sc->sc_imsglen == 2 && IS2BYTEMSG(sc->sc_imsg[0]))
|
||||
if (sc->sc_imsglen == 2 && MSG_IS2BYTE(sc->sc_imsg[0]))
|
||||
goto gotit;
|
||||
if (sc->sc_imsglen >= 3 && ISEXTMSG(sc->sc_imsg[0]) &&
|
||||
if (sc->sc_imsglen >= 3 && MSG_ISEXTENDED(sc->sc_imsg[0]) &&
|
||||
sc->sc_imsglen == sc->sc_imsg[1] + 2)
|
||||
goto gotit;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mha.c,v 1.22 2001/04/25 17:53:26 bouyer Exp $ */
|
||||
/* $NetBSD: mha.c,v 1.23 2001/11/04 12:04:14 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996-1999 The NetBSD Foundation, Inc.
|
||||
|
@ -1034,10 +1034,6 @@ mha_dequeue(sc, acb)
|
|||
sc->sc_msgpriq |= (m); \
|
||||
} while (0)
|
||||
|
||||
#define IS1BYTEMSG(m) (((m) != 0x01 && (m) < 0x20) || (m) >= 0x80)
|
||||
#define IS2BYTEMSG(m) (((m) & 0xf0) == 0x20)
|
||||
#define ISEXTMSG(m) ((m) == 0x01)
|
||||
|
||||
/*
|
||||
* Precondition:
|
||||
* The SCSI bus is already in the MSGI phase and there is a message byte
|
||||
|
@ -1094,11 +1090,11 @@ mha_msgin(sc)
|
|||
* it should not effect performance
|
||||
* significantly.
|
||||
*/
|
||||
if (sc->sc_imlen == 1 && IS1BYTEMSG(sc->sc_imess[0]))
|
||||
if (sc->sc_imlen == 1 && MSG_IS1BYTE(sc->sc_imess[0]))
|
||||
goto gotit;
|
||||
if (sc->sc_imlen == 2 && IS2BYTEMSG(sc->sc_imess[0]))
|
||||
if (sc->sc_imlen == 2 && MSG_IS2BYTE(sc->sc_imess[0]))
|
||||
goto gotit;
|
||||
if (sc->sc_imlen >= 3 && ISEXTMSG(sc->sc_imess[0]) &&
|
||||
if (sc->sc_imlen >= 3 && MSG_ISEXTENDED(sc->sc_imess[0]) &&
|
||||
sc->sc_imlen == sc->sc_imess[1] + 2)
|
||||
goto gotit;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: aic6360.c,v 1.74 2001/07/07 16:13:45 thorpej Exp $ */
|
||||
/* $NetBSD: aic6360.c,v 1.75 2001/11/04 12:05:41 tsutsui Exp $ */
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#ifdef DDB
|
||||
|
@ -974,10 +974,6 @@ aic_dequeue(struct aic_softc *sc, struct aic_acb *acb)
|
|||
* INTERRUPT/PROTOCOL ENGINE
|
||||
*/
|
||||
|
||||
#define IS1BYTEMSG(m) (((m) != 0x01 && (m) < 0x20) || (m) >= 0x80)
|
||||
#define IS2BYTEMSG(m) (((m) & 0xf0) == 0x20)
|
||||
#define ISEXTMSG(m) ((m) == 0x01)
|
||||
|
||||
/*
|
||||
* Precondition:
|
||||
* The SCSI bus is already in the MSGI phase and there is a message byte
|
||||
|
@ -1050,11 +1046,11 @@ nextbyte:
|
|||
* it should not affect performance
|
||||
* significantly.
|
||||
*/
|
||||
if (n == 1 && IS1BYTEMSG(sc->sc_imess[0]))
|
||||
if (n == 1 && MSG_IS1BYTE(sc->sc_imess[0]))
|
||||
break;
|
||||
if (n == 2 && IS2BYTEMSG(sc->sc_imess[0]))
|
||||
if (n == 2 && MSG_IS2BYTE(sc->sc_imess[0]))
|
||||
break;
|
||||
if (n >= 3 && ISEXTMSG(sc->sc_imess[0]) &&
|
||||
if (n >= 3 && MSG_ISEXTENDED(sc->sc_imess[0]) &&
|
||||
n == sc->sc_imess[1] + 2)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mb89352.c,v 1.8 2001/07/07 16:13:49 thorpej Exp $ */
|
||||
/* $NetBSD: mb89352.c,v 1.9 2001/11/04 12:05:42 tsutsui Exp $ */
|
||||
/* NecBSD: mb89352.c,v 1.4 1998/03/14 07:31:20 kmatsuda Exp */
|
||||
|
||||
#ifdef DDB
|
||||
|
@ -872,10 +872,6 @@ spc_dequeue(sc, acb)
|
|||
* INTERRUPT/PROTOCOL ENGINE
|
||||
*/
|
||||
|
||||
#define IS1BYTEMSG(m) (((m) != 0x01 && (m) < 0x20) || (m) >= 0x80)
|
||||
#define IS2BYTEMSG(m) (((m) & 0xf0) == 0x20)
|
||||
#define ISEXTMSG(m) ((m) == 0x01)
|
||||
|
||||
/*
|
||||
* Precondition:
|
||||
* The SCSI bus is already in the MSGI phase and there is a message byte
|
||||
|
@ -969,11 +965,11 @@ nextbyte:
|
|||
* it should not affect performance
|
||||
* significantly.
|
||||
*/
|
||||
if (n == 1 && IS1BYTEMSG(sc->sc_imess[0]))
|
||||
if (n == 1 && MSG_IS1BYTE(sc->sc_imess[0]))
|
||||
break;
|
||||
if (n == 2 && IS2BYTEMSG(sc->sc_imess[0]))
|
||||
if (n == 2 && MSG_IS2BYTE(sc->sc_imess[0]))
|
||||
break;
|
||||
if (n >= 3 && ISEXTMSG(sc->sc_imess[0]) &&
|
||||
if (n >= 3 && MSG_ISEXTENDED(sc->sc_imess[0]) &&
|
||||
n == sc->sc_imess[1] + 2)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ncr5380sbc.c,v 1.43 2001/07/08 18:06:46 wiz Exp $ */
|
||||
/* $NetBSD: ncr5380sbc.c,v 1.44 2001/11/04 12:05:42 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 David Jones, Gordon W. Ross
|
||||
|
@ -1536,10 +1536,6 @@ success:
|
|||
* NOOP if nothing else fits the bill ...
|
||||
*/
|
||||
|
||||
#define IS1BYTEMSG(m) (((m) != 0x01 && (m) < 0x20) || (m) >= 0x80)
|
||||
#define IS2BYTEMSG(m) (((m) & 0xf0) == 0x20)
|
||||
#define ISEXTMSG(m) ((m) == 0x01)
|
||||
|
||||
/*
|
||||
* Precondition:
|
||||
* The SCSI bus is already in the MSGI phase and there is a message byte
|
||||
|
@ -1629,11 +1625,11 @@ nextbyte:
|
|||
* it should not affect performance
|
||||
* significantly.
|
||||
*/
|
||||
if (n == 1 && IS1BYTEMSG(sc->sc_imess[0]))
|
||||
if (n == 1 && MSG_IS1BYTE(sc->sc_imess[0]))
|
||||
goto have_msg;
|
||||
if (n == 2 && IS2BYTEMSG(sc->sc_imess[0]))
|
||||
if (n == 2 && MSG_IS2BYTE(sc->sc_imess[0]))
|
||||
goto have_msg;
|
||||
if (n >= 3 && ISEXTMSG(sc->sc_imess[0]) &&
|
||||
if (n >= 3 && MSG_ISEXTENDED(sc->sc_imess[0]) &&
|
||||
n == sc->sc_imess[1] + 2)
|
||||
goto have_msg;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ncr53c9x.c,v 1.84 2001/07/26 15:51:04 tsutsui Exp $ */
|
||||
/* $NetBSD: ncr53c9x.c,v 1.85 2001/11/04 12:05:42 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -1490,23 +1490,15 @@ abort:
|
|||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* XXX this might be common thing(check with scsipi)
|
||||
*/
|
||||
#define IS1BYTEMSG(m) (((m) != 1 && (m) < 0x20) || (m) & 0x80)
|
||||
#define IS2BYTEMSG(m) (((m) & 0xf0) == 0x20)
|
||||
#define ISEXTMSG(m) ((m) == 1)
|
||||
|
||||
static inline int
|
||||
__verify_msg_format(u_char *p, int len)
|
||||
{
|
||||
|
||||
if (len == 1 && IS1BYTEMSG(p[0]))
|
||||
if (len == 1 && MSG_IS1BYTE(p[0]))
|
||||
return 1;
|
||||
if (len == 2 && IS2BYTEMSG(p[0]))
|
||||
if (len == 2 && MSG_IS2BYTE(p[0]))
|
||||
return 1;
|
||||
if (len >= 3 && ISEXTMSG(p[0]) &&
|
||||
if (len >= 3 && MSG_ISEXTENDED(p[0]) &&
|
||||
len == p[1] + 2)
|
||||
return 1;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sunscpal.c,v 1.7 2001/08/17 00:24:09 fredette Exp $ */
|
||||
/* $NetBSD: sunscpal.c,v 1.8 2001/11/04 12:05:42 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Matthew Fredette
|
||||
|
@ -1300,10 +1300,6 @@ success:
|
|||
* NOOP if nothing else fits the bill ...
|
||||
*/
|
||||
|
||||
#define IS1BYTEMSG(m) (((m) != 0x01 && (m) < 0x20) || (m) >= 0x80)
|
||||
#define IS2BYTEMSG(m) (((m) & 0xf0) == 0x20)
|
||||
#define ISEXTMSG(m) ((m) == 0x01)
|
||||
|
||||
/*
|
||||
* Precondition:
|
||||
* The SCSI bus is already in the MSGI phase and there is a message byte
|
||||
|
@ -1388,11 +1384,11 @@ nextbyte:
|
|||
* it should not affect performance
|
||||
* significantly.
|
||||
*/
|
||||
if (n == 1 && IS1BYTEMSG(sc->sc_imess[0]))
|
||||
if (n == 1 && MSG_IS1BYTE(sc->sc_imess[0]))
|
||||
goto have_msg;
|
||||
if (n == 2 && IS2BYTEMSG(sc->sc_imess[0]))
|
||||
if (n == 2 && MSG_IS2BYTE(sc->sc_imess[0]))
|
||||
goto have_msg;
|
||||
if (n >= 3 && ISEXTMSG(sc->sc_imess[0]) &&
|
||||
if (n >= 3 && MSG_ISEXTENDED(sc->sc_imess[0]) &&
|
||||
n == sc->sc_imess[1] + 2)
|
||||
goto have_msg;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue