Use a #define instead of a magic number

This commit is contained in:
skrll 2017-11-17 13:08:48 +00:00
parent ff1dbb860a
commit d42627d4ac
2 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_run.c,v 1.23 2017/11/17 12:55:16 skrll Exp $ */ /* $NetBSD: if_run.c,v 1.24 2017/11/17 13:08:48 skrll Exp $ */
/* $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */ /* $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */
/*- /*-
@ -23,7 +23,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.23 2017/11/17 12:55:16 skrll Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.24 2017/11/17 13:08:48 skrll Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_usb.h" #include "opt_usb.h"
@ -599,13 +599,13 @@ run_attach(device_t parent, device_t self, void *aux)
if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN) { if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN) {
sc->rxq.pipe_no = ed->bEndpointAddress; sc->rxq.pipe_no = ed->bEndpointAddress;
nrx++; nrx++;
} else if (ntx < 4) { } else if (ntx < RUN_MAXEPOUT) {
sc->txq[ntx].pipe_no = ed->bEndpointAddress; sc->txq[ntx].pipe_no = ed->bEndpointAddress;
ntx++; ntx++;
} }
} }
/* make sure we've got them all */ /* make sure we've got them all */
if (nrx < 1 || ntx < 4) { if (nrx < 1 || ntx < RUN_MAXEPOUT) {
aprint_error_dev(sc->sc_dev, "missing endpoint\n"); aprint_error_dev(sc->sc_dev, "missing endpoint\n");
return; return;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_runvar.h,v 1.3 2016/09/16 09:25:30 mlelstv Exp $ */ /* $NetBSD: if_runvar.h,v 1.4 2017/11/17 13:08:48 skrll Exp $ */
/* $OpenBSD: if_runvar.h,v 1.8 2010/02/08 18:46:47 damien Exp $ */ /* $OpenBSD: if_runvar.h,v 1.8 2010/02/08 18:46:47 damien Exp $ */
/*- /*-
@ -132,6 +132,8 @@ struct run_node {
uint8_t ctl_ridx[IEEE80211_RATE_MAXSIZE]; uint8_t ctl_ridx[IEEE80211_RATE_MAXSIZE];
}; };
#define RUN_MAXEPOUT 4
struct run_softc { struct run_softc {
device_t sc_dev; device_t sc_dev;
struct ethercom sc_ec; struct ethercom sc_ec;
@ -191,7 +193,7 @@ struct run_softc {
callout_t calib_to; callout_t calib_to;
struct run_rx_ring rxq; struct run_rx_ring rxq;
struct run_tx_ring txq[4]; struct run_tx_ring txq[RUN_MAXEPOUT];
struct run_host_cmd_ring cmdq; struct run_host_cmd_ring cmdq;
uint8_t qfullmsk; uint8_t qfullmsk;
int sc_tx_timer; int sc_tx_timer;