diff options
author | rik <rik@FreeBSD.org> | 2008-06-30 21:18:27 +0000 |
---|---|---|
committer | rik <rik@FreeBSD.org> | 2008-06-30 21:18:27 +0000 |
commit | b49a85befd88be2728fef2765dde3ad4793511cc (patch) | |
tree | fc0d5f8df2864c985a23cc83800e237fc998a308 /sys | |
parent | 8805d22e343f9c4b23897204b50dcd29aed7ca3f (diff) | |
download | FreeBSD-src-b49a85befd88be2728fef2765dde3ad4793511cc.zip FreeBSD-src-b49a85befd88be2728fef2765dde3ad4793511cc.tar.gz |
Do not set IFF_DEBUG directly from the driver.
MFC after: 1 month.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ce/ceddk.h | 1 | ||||
-rw-r--r-- | sys/dev/ce/if_ce.c | 19 | ||||
-rw-r--r-- | sys/dev/cp/cpddk.h | 1 | ||||
-rw-r--r-- | sys/dev/cp/if_cp.c | 19 | ||||
-rw-r--r-- | sys/dev/ctau/ctddk.h | 1 | ||||
-rw-r--r-- | sys/dev/ctau/if_ct.c | 19 | ||||
-rw-r--r-- | sys/dev/cx/cxddk.h | 1 | ||||
-rw-r--r-- | sys/dev/cx/if_cx.c | 31 |
8 files changed, 63 insertions, 29 deletions
diff --git a/sys/dev/ce/ceddk.h b/sys/dev/ce/ceddk.h index 8cd8c67..f584400 100644 --- a/sys/dev/ce/ceddk.h +++ b/sys/dev/ce/ceddk.h @@ -72,6 +72,7 @@ typedef struct _ce_chan_t { TAU32_UserRequest *rx_queue; TAU32_UserRequest *tx_queue; unsigned char debug; + unsigned char debug_shadow; void (*transmit) (struct _ce_chan_t*, void*, int); void (*receive) (struct _ce_chan_t*, unsigned char*, int); void (*error) (struct _ce_chan_t*, int); diff --git a/sys/dev/ce/if_ce.c b/sys/dev/ce/if_ce.c index 8f93667..396d670 100644 --- a/sys/dev/ce/if_ce.c +++ b/sys/dev/ce/if_ce.c @@ -962,8 +962,8 @@ static int ce_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data) if (! (ifp->if_flags & IFF_DEBUG)) d->chan->debug = 0; - else if (! d->chan->debug) - d->chan->debug = 1; + else + d->chan->debug = d->chan->debug_shadow; switch (cmd) { default: CE_DEBUG2 (d, ("ioctl 0x%lx\n", cmd)); return 0; @@ -1621,12 +1621,17 @@ static int ce_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc #endif if (error) return error; - d->chan->debug = *(int*)data; #ifndef NETGRAPH - if (d->chan->debug) - d->ifp->if_flags |= IFF_DEBUG; - else - d->ifp->if_flags &= ~IFF_DEBUG; + /* + * The debug_shadow is always greater than zero for logic + * simplicity. For switching debug off the IFF_DEBUG is + * responsible. + */ + d->chan->debug_shadow = (*(int*)data) ? (*(int*)data) : 1; + if (d->ifp->if_flags & IFF_DEBUG) + d->chan->debug = d->chan->debug_shadow; +#else + d->chan->debug = *(int*)data; #endif return 0; diff --git a/sys/dev/cp/cpddk.h b/sys/dev/cp/cpddk.h index 3ff40bb..fcdb0d0 100644 --- a/sys/dev/cp/cpddk.h +++ b/sys/dev/cp/cpddk.h @@ -205,6 +205,7 @@ typedef struct _cp_chan_t { void *tag [NTBUF]; /* system dependent data per buffer */ void *sys; /* system dependent data per channel */ unsigned char debug; /* debug level, 0..2 */ + unsigned char debug_shadow; /* debug shadow */ void (*transmit) (struct _cp_chan_t *c, void *tag, int len); void (*receive) (struct _cp_chan_t *c, unsigned char *data, int len); diff --git a/sys/dev/cp/if_cp.c b/sys/dev/cp/if_cp.c index dbe40bc..36b12ab 100644 --- a/sys/dev/cp/if_cp.c +++ b/sys/dev/cp/if_cp.c @@ -733,8 +733,8 @@ static int cp_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data) if (! (ifp->if_flags & IFF_DEBUG)) d->chan->debug = 0; - else if (! d->chan->debug) - d->chan->debug = 1; + else + d->chan->debug = d->chan->debug_shadow; switch (cmd) { default: CP_DEBUG2 (d, ("ioctl 0x%lx\n", cmd)); return 0; @@ -1349,12 +1349,17 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc error = priv_check (td, PRIV_DRIVER); if (error) return error; - d->chan->debug = *(int*)data; #ifndef NETGRAPH - if (d->chan->debug) - d->ifp->if_flags |= IFF_DEBUG; - else - d->ifp->if_flags &= ~IFF_DEBUG; + /* + * The debug_shadow is always greater than zero for logic + * simplicity. For switching debug off the IFF_DEBUG is + * responsible. + */ + d->chan->debug_shadow = (*(int*)data) ? (*(int*)data) : 1; + if (d->ifp->if_flags & IFF_DEBUG) + d->chan->debug = d->chan->debug_shadow; +#else + d->chan->debug = *(int*)data; #endif return 0; diff --git a/sys/dev/ctau/ctddk.h b/sys/dev/ctau/ctddk.h index 9962090..be0a092 100644 --- a/sys/dev/ctau/ctddk.h +++ b/sys/dev/ctau/ctddk.h @@ -412,6 +412,7 @@ typedef struct _ct_chan_t { void *attach [NBUF]; /* system dependent data per buffer */ void *sys; /* system dependent data per channel */ int debug; + int debug_shadow; int e1_first_int; unsigned char *sccrx, *scctx; /* pointers to SCC rx and tx buffers */ diff --git a/sys/dev/ctau/if_ct.c b/sys/dev/ctau/if_ct.c index 25e927a..f2d876d 100644 --- a/sys/dev/ctau/if_ct.c +++ b/sys/dev/ctau/if_ct.c @@ -949,8 +949,8 @@ static int ct_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data) if (! (ifp->if_flags & IFF_DEBUG)) d->chan->debug = 0; - else if (! d->chan->debug) - d->chan->debug = 1; + else + d->chan->debug = d->chan->debug_shadow; switch (cmd) { default: CT_DEBUG2 (d, ("ioctl 0x%lx\n", cmd)); return 0; @@ -1529,12 +1529,17 @@ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc error = priv_check (td, PRIV_DRIVER); if (error) return error; - c->debug = *(int*)data; #ifndef NETGRAPH - if (d->chan->debug) - d->ifp->if_flags |= IFF_DEBUG; - else - d->ifp->if_flags &= (~IFF_DEBUG); + /* + * The debug_shadow is always greater than zero for logic + * simplicity. For switching debug off the IFF_DEBUG is + * responsible. + */ + c->debug_shadow = (*(int*)data) ? (*(int*)data) : 1; + if (d->ifp->if_flags & IFF_DEBUG) + c->debug = c->debug_shadow; +#else + c->debug = *(int*)data; #endif return 0; diff --git a/sys/dev/cx/cxddk.h b/sys/dev/cx/cxddk.h index bd95aa6..69f0693 100644 --- a/sys/dev/cx/cxddk.h +++ b/sys/dev/cx/cxddk.h @@ -337,6 +337,7 @@ typedef struct _cx_chan_t { void *sys; int debug; + int debug_shadow; void *attach [2]; char *received_data; int received_len; diff --git a/sys/dev/cx/if_cx.c b/sys/dev/cx/if_cx.c index 34ccd5a..be164bd 100644 --- a/sys/dev/cx/if_cx.c +++ b/sys/dev/cx/if_cx.c @@ -1102,10 +1102,14 @@ static int cx_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data) if (error) return error; + s = splhigh (); + CX_LOCK (bd); if (! (ifp->if_flags & IFF_DEBUG)) d->chan->debug = 0; - else if (! d->chan->debug) - d->chan->debug = 1; + else + d->chan->debug = d->chan->debug_shadow; + CX_UNLOCK (bd); + splx (s); switch (cmd) { default: CX_DEBUG2 (d, ("ioctl 0x%lx\n", cmd)); return 0; @@ -1745,6 +1749,8 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc cx_enable_receive (c, 0); cx_enable_transmit (c, 0); } else if (c->mode == M_ASYNC && *(int*)data == SERIAL_HDLC) { + if (d->ifp->if_flags & IFF_DEBUG) + c->debug = c->debug_shadow; cx_set_mode (c, M_HDLC); cx_enable_receive (c, 1); cx_enable_transmit (c, 1); @@ -1913,15 +1919,24 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc return error; s = splhigh (); CX_LOCK (bd); +#ifndef NETGRAPH + if (c->mode == M_ASYNC) { + c->debug = *(int*)data; + } else { + /* + * The debug_shadow is always greater than zero for + * logic simplicity. For switching debug off the + * IFF_DEBUG is responsible (for !M_ASYNC mode). + */ + c->debug_shadow = (*(int*)data) ? (*(int*)data) : 1; + if (d->ifp->if_flags & IFF_DEBUG) + c->debug = c->debug_shadow; + } +#else c->debug = *(int*)data; +#endif CX_UNLOCK (bd); splx (s); -#ifndef NETGRAPH - if (d->chan->debug) - d->ifp->if_flags |= IFF_DEBUG; - else - d->ifp->if_flags &= (~IFF_DEBUG); -#endif return 0; } |