summaryrefslogtreecommitdiffstats
path: root/sys/dev/cp
diff options
context:
space:
mode:
authorrik <rik@FreeBSD.org>2008-06-30 21:18:27 +0000
committerrik <rik@FreeBSD.org>2008-06-30 21:18:27 +0000
commitb49a85befd88be2728fef2765dde3ad4793511cc (patch)
treefc0d5f8df2864c985a23cc83800e237fc998a308 /sys/dev/cp
parent8805d22e343f9c4b23897204b50dcd29aed7ca3f (diff)
downloadFreeBSD-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/dev/cp')
-rw-r--r--sys/dev/cp/cpddk.h1
-rw-r--r--sys/dev/cp/if_cp.c19
2 files changed, 13 insertions, 7 deletions
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;
OpenPOWER on IntegriCloud