diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ar/if_ar.c | 30 | ||||
-rw-r--r-- | sys/dev/ar/if_ar_isa.c | 30 | ||||
-rw-r--r-- | sys/dev/lmc/if_lmc.c | 33 | ||||
-rw-r--r-- | sys/dev/musycc/musycc.c | 19 | ||||
-rw-r--r-- | sys/dev/sr/if_sr.c | 30 | ||||
-rw-r--r-- | sys/dev/sr/if_sr_isa.c | 30 | ||||
-rw-r--r-- | sys/dev/usb/udbp.c | 49 |
7 files changed, 114 insertions, 107 deletions
diff --git a/sys/dev/ar/if_ar.c b/sys/dev/ar/if_ar.c index 722a133..942b021 100644 --- a/sys/dev/ar/if_ar.c +++ b/sys/dev/ar/if_ar.c @@ -511,10 +511,10 @@ arattach(struct ar_hardc *hc) return (0); sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit); if (ng_name_node(sc->node, sc->nodename)) { - ng_unref(sc->node); /* drop it again */ + NG_NODE_UNREF(sc->node); /* drop it again */ return (0); } - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); callout_handle_init(&sc->handle); sc->xmitq.ifq_maxlen = IFQ_MAXLEN; sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN; @@ -2186,13 +2186,13 @@ ngar_constructor(node_p node) static int ngar_newhook(node_p node, hook_p hook, const char *name) { - struct ar_softc * sc = node->private; + struct ar_softc * sc = NG_NODE_PRIVATE(node); /* * check if it's our friend the debug hook */ if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) { - hook->private = NULL; /* paranoid */ + NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */ sc->debug_hook = hook; return (0); } @@ -2203,7 +2203,7 @@ ngar_newhook(node_p node, hook_p hook, const char *name) if (strcmp(name, NG_AR_HOOK_RAW) != 0) { return (EINVAL); } - hook->private = sc; + NG_HOOK_SET_PRIVATE(hook, sc); sc->hook = hook; sc->datahooks++; ar_up(sc); @@ -2223,7 +2223,7 @@ ngar_rcvmsg(node_p node, item_p item, hook_p lasthook) struct ng_mesg *msg; NGI_GET_MSG(item, msg); - sc = node->private; + sc = NG_NODE_PRIVATE(node); switch (msg->header.typecookie) { case NG_AR_COOKIE: error = EINVAL; @@ -2281,7 +2281,7 @@ ngar_rcvdata(hook_p hook, item_p item) { int s; int error = 0; - struct ar_softc * sc = hook->node->private; + struct ar_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); struct ifqueue *xmitq_p; struct mbuf *m; meta_p meta; @@ -2292,7 +2292,7 @@ ngar_rcvdata(hook_p hook, item_p item) /* * data doesn't come in from just anywhere (e.g control hook) */ - if ( hook->private == NULL) { + if ( NG_HOOK_PRIVATE(hook) == NULL) { error = ENETDOWN; goto bad; } @@ -2338,10 +2338,10 @@ bad: static int ngar_shutdown(node_p node) { - struct ar_softc * sc = node->private; + struct ar_softc * sc = NG_NODE_PRIVATE(node); ar_down(sc); - ng_unref(node); + NG_NODE_UNREF(node); /* XXX need to drain the output queues! */ /* The node is dead, long live the node! */ @@ -2352,10 +2352,10 @@ ngar_shutdown(node_p node) if (ng_name_node(sc->node, sc->nodename)) { sc->node = NULL; printf("node naming failed\n"); - ng_unref(sc->node); /* node dissappears */ + NG_NODE_UNREF(sc->node); /* node dissappears */ return (0); } - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); sc->running = 0; return (0); } @@ -2365,7 +2365,7 @@ static int ngar_connect(hook_p hook) { /* probably not at splnet, force outward queueing */ - hook->peer->flags |= HK_QUEUE; + NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook)); /* be really amiable and just say "YUP that's OK by me! " */ return (0); } @@ -2384,12 +2384,12 @@ ngar_connect(hook_p hook) static int ngar_disconnect(hook_p hook) { - struct ar_softc * sc = hook->node->private; + struct ar_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); int s; /* * If it's the data hook, then free resources etc. */ - if (hook->private) { + if (NG_HOOK_PRIVATE(hook)) { s = splimp(); sc->datahooks--; if (sc->datahooks == 0) diff --git a/sys/dev/ar/if_ar_isa.c b/sys/dev/ar/if_ar_isa.c index 722a133..942b021 100644 --- a/sys/dev/ar/if_ar_isa.c +++ b/sys/dev/ar/if_ar_isa.c @@ -511,10 +511,10 @@ arattach(struct ar_hardc *hc) return (0); sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit); if (ng_name_node(sc->node, sc->nodename)) { - ng_unref(sc->node); /* drop it again */ + NG_NODE_UNREF(sc->node); /* drop it again */ return (0); } - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); callout_handle_init(&sc->handle); sc->xmitq.ifq_maxlen = IFQ_MAXLEN; sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN; @@ -2186,13 +2186,13 @@ ngar_constructor(node_p node) static int ngar_newhook(node_p node, hook_p hook, const char *name) { - struct ar_softc * sc = node->private; + struct ar_softc * sc = NG_NODE_PRIVATE(node); /* * check if it's our friend the debug hook */ if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) { - hook->private = NULL; /* paranoid */ + NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */ sc->debug_hook = hook; return (0); } @@ -2203,7 +2203,7 @@ ngar_newhook(node_p node, hook_p hook, const char *name) if (strcmp(name, NG_AR_HOOK_RAW) != 0) { return (EINVAL); } - hook->private = sc; + NG_HOOK_SET_PRIVATE(hook, sc); sc->hook = hook; sc->datahooks++; ar_up(sc); @@ -2223,7 +2223,7 @@ ngar_rcvmsg(node_p node, item_p item, hook_p lasthook) struct ng_mesg *msg; NGI_GET_MSG(item, msg); - sc = node->private; + sc = NG_NODE_PRIVATE(node); switch (msg->header.typecookie) { case NG_AR_COOKIE: error = EINVAL; @@ -2281,7 +2281,7 @@ ngar_rcvdata(hook_p hook, item_p item) { int s; int error = 0; - struct ar_softc * sc = hook->node->private; + struct ar_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); struct ifqueue *xmitq_p; struct mbuf *m; meta_p meta; @@ -2292,7 +2292,7 @@ ngar_rcvdata(hook_p hook, item_p item) /* * data doesn't come in from just anywhere (e.g control hook) */ - if ( hook->private == NULL) { + if ( NG_HOOK_PRIVATE(hook) == NULL) { error = ENETDOWN; goto bad; } @@ -2338,10 +2338,10 @@ bad: static int ngar_shutdown(node_p node) { - struct ar_softc * sc = node->private; + struct ar_softc * sc = NG_NODE_PRIVATE(node); ar_down(sc); - ng_unref(node); + NG_NODE_UNREF(node); /* XXX need to drain the output queues! */ /* The node is dead, long live the node! */ @@ -2352,10 +2352,10 @@ ngar_shutdown(node_p node) if (ng_name_node(sc->node, sc->nodename)) { sc->node = NULL; printf("node naming failed\n"); - ng_unref(sc->node); /* node dissappears */ + NG_NODE_UNREF(sc->node); /* node dissappears */ return (0); } - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); sc->running = 0; return (0); } @@ -2365,7 +2365,7 @@ static int ngar_connect(hook_p hook) { /* probably not at splnet, force outward queueing */ - hook->peer->flags |= HK_QUEUE; + NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook)); /* be really amiable and just say "YUP that's OK by me! " */ return (0); } @@ -2384,12 +2384,12 @@ ngar_connect(hook_p hook) static int ngar_disconnect(hook_p hook) { - struct ar_softc * sc = hook->node->private; + struct ar_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); int s; /* * If it's the data hook, then free resources etc. */ - if (hook->private) { + if (NG_HOOK_PRIVATE(hook)) { s = splimp(); sc->datahooks--; if (sc->datahooks == 0) diff --git a/sys/dev/lmc/if_lmc.c b/sys/dev/lmc/if_lmc.c index bec558d..d6b586150 100644 --- a/sys/dev/lmc/if_lmc.c +++ b/sys/dev/lmc/if_lmc.c @@ -1132,10 +1132,10 @@ lmc_attach(lmc_softc_t * const sc) return (0); sprintf(sc->lmc_nodename, "%s%d", NG_LMC_NODE_TYPE, sc->lmc_unit); if (ng_name_node(sc->lmc_node, sc->lmc_nodename)) { - ng_unref(sc->lmc_node); /* make it go away again */ + NG_NODE_UNREF(sc->lmc_node); /* make it go away again */ return (0); } - sc->lmc_node->private = sc; + NG_NODE_SET_PRIVATE(sc->lmc_node, sc); callout_handle_init(&sc->lmc_handle); sc->lmc_xmitq.ifq_maxlen = IFQ_MAXLEN; sc->lmc_xmitq_hipri.ifq_maxlen = IFQ_MAXLEN; @@ -1265,13 +1265,13 @@ ng_lmc_constructor(node_p node) static int ng_lmc_newhook(node_p node, hook_p hook, const char *name) { - lmc_softc_t * sc = (lmc_softc_t *) node->private; + lmc_softc_t * sc = NG_NODE_PRIVATE(node); /* * check if it's our friend the debug hook */ if (strcmp(name, NG_LMC_HOOK_DEBUG) == 0) { - hook->private = NULL; /* paranoid */ + NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */ sc->lmc_debug_hook = hook; return (0); } @@ -1282,7 +1282,7 @@ ng_lmc_newhook(node_p node, hook_p hook, const char *name) if (strcmp(name, NG_LMC_HOOK_RAW) != 0) { return (EINVAL); } - hook->private = sc; + NG_HOOK_SET_PRIVATE(hook, sc); sc->lmc_hook = hook; sc->lmc_datahooks++; lmc_ifup(sc); @@ -1296,7 +1296,7 @@ ng_lmc_newhook(node_p node, hook_p hook, const char *name) static int ng_lmc_rcvmsg(node_p node, item_p item, hook_p lasthook) { - lmc_softc_t *sc = (lmc_softc_t *) node->private; + lmc_softc_t *sc = NG_NODE_PRIVATE(node); struct ng_mesg *resp = NULL; int error = 0; struct ng_mesg *msg; @@ -1390,7 +1390,7 @@ ng_lmc_rcvdata(hook_p hook, item_p item) { int s; int error = 0; - lmc_softc_t * sc = (lmc_softc_t *) hook->node->private; + lmc_softc_t * sc = (lmc_softc_t *) NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); struct ifqueue *xmitq_p; struct mbuf *m; meta_p meta; @@ -1403,7 +1403,7 @@ ng_lmc_rcvdata(hook_p hook, item_p item) /* * data doesn't come in from just anywhere (e.g control hook) */ - if ( hook->private == NULL) { + if ( NG_HOOK_PRIVATE(hook) == NULL) { error = ENETDOWN; goto bad; } @@ -1449,16 +1449,15 @@ bad: static int ng_lmc_rmnode(node_p node) { - lmc_softc_t * sc = (lmc_softc_t *) node->private; + lmc_softc_t * sc = NG_NODE_PRIVATE(node); lmc_ifdown(sc); /* * Get rid of the old node. */ - node->flags |= NG_INVALID; - node->private = NULL; - ng_unref(node); + NG_NODE_SET_PRIVATE(node, NULL); + NG_NODE_UNREF(node); /* * Create a new node. This is basically what a device @@ -1470,10 +1469,10 @@ ng_lmc_rmnode(node_p node) sprintf(sc->lmc_nodename, "%s%d", NG_LMC_NODE_TYPE, sc->lmc_unit); if (ng_name_node(sc->lmc_node, sc->lmc_nodename)) { sc->lmc_node = NULL; /* to be sure */ - ng_unref(sc->lmc_node); /* make it go away */ + NG_NODE_UNREF(sc->lmc_node); /* make it go away */ return (0); } - sc->lmc_node->private = sc; + NG_NODE_SET_PRIVATE(sc->lmc_node, sc); callout_handle_init(&sc->lmc_handle); sc->lmc_running = 0; /* @@ -1488,7 +1487,7 @@ static int ng_lmc_connect(hook_p hook) { /* We are probably not at splnet.. force outward queueing */ - hook->peer->flags |= HK_QUEUE; + NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook)); /* be really amiable and just say "YUP that's OK by me! " */ return (0); } @@ -1506,12 +1505,12 @@ ng_lmc_connect(hook_p hook) static int ng_lmc_disconnect(hook_p hook) { - lmc_softc_t * sc = (lmc_softc_t *) hook->node->private; + lmc_softc_t * sc = (lmc_softc_t *) NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); int s; /* * If it's the data hook, then free resources etc. */ - if (hook->private) { + if (NG_HOOK_PRIVATE(hook)) { s = splimp(); sc->lmc_datahooks--; if (sc->lmc_datahooks == 0) diff --git a/sys/dev/musycc/musycc.c b/sys/dev/musycc/musycc.c index 6153a2a..f61ef5e 100644 --- a/sys/dev/musycc/musycc.c +++ b/sys/dev/musycc/musycc.c @@ -855,7 +855,7 @@ musycc_config(node_p node, char *set, char *ret) enum framing wframing; int i; - sc = node->private; + sc = NG_NODE_PRIVATE(node); csc = sc->csc; if (csc->state == C_IDLE) init_card(csc); @@ -941,7 +941,7 @@ musycc_rcvmsg(node_p node, item_p item, hook_p lasthook) NGI_GET_MSG(item, msg); - sc = node->private; + sc = NG_NODE_PRIVATE(node); if (msg->header.typecookie != NGM_GENERIC_COOKIE) goto out; @@ -995,7 +995,7 @@ musycc_newhook(node_p node, hook_p hook, const char *name) u_int32_t ts, chan; int nbit; - sc = node->private; + sc = NG_NODE_PRIVATE(node); csc = sc->csc; while (csc->state != C_RUNNING) @@ -1033,7 +1033,7 @@ musycc_newhook(node_p node, hook_p hook, const char *name) sch->ts = ts; sch->hook = hook; sch->tx_limit = nbit * 8; - hook->private = sch; + NG_HOOK_SET_PRIVATE(hook, sch); return(0); } @@ -1049,7 +1049,7 @@ musycc_rcvdata(hook_p hook, item_p item) struct mbuf *m2; struct mbuf *m; - sch = hook->private; + sch = NG_HOOK_PRIVATE(hook); sc = sch->sc; csc = sc->csc; ch = sch->chan; @@ -1116,7 +1116,7 @@ musycc_connect(hook_p hook) int nts, nbuf, i, nmd, ch; struct mbuf *m; - sch = hook->private; + sch = NG_HOOK_PRIVATE(hook); sc = sch->sc; csc = sc->csc; ch = sch->chan; @@ -1231,7 +1231,7 @@ musycc_connect(hook_p hook) tsleep(&sc->last, PZERO + PCATCH, "con4", hz); sc->reg->srd = sc->last = 0x0820 + ch; tsleep(&sc->last, PZERO + PCATCH, "con3", hz); - hook->peer->flags |= HK_QUEUE; + NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook)); return (0); @@ -1254,7 +1254,7 @@ musycc_disconnect(hook_p hook) struct schan *sch; int i, ch; - sch = hook->private; + sch = NG_HOOK_PRIVATE(hook); sc = sch->sc; csc = sc->csc; ch = sch->chan; @@ -1452,12 +1452,13 @@ musycc_attach(device_t self) printf("ng_make_node_common() failed %d\n", error); continue; } - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); sprintf(sc->nodename, "sync-%d-%d-%d", csc->bus, csc->slot, i); error = ng_name_node(sc->node, sc->nodename); + /* XXX Apparently failure isn't a problem */ } csc->ram = (struct globalr *)&csc->serial[0].mycg->cg; sc = &csc->serial[0]; diff --git a/sys/dev/sr/if_sr.c b/sys/dev/sr/if_sr.c index a7ba8e9..830b595 100644 --- a/sys/dev/sr/if_sr.c +++ b/sys/dev/sr/if_sr.c @@ -936,10 +936,10 @@ srattach(struct sr_hardc *hc) return (0); sprintf(sc->nodename, "%s%d", NG_SR_NODE_TYPE, sc->unit); if (ng_name_node(sc->node, sc->nodename)) { - ng_unref(sc->node); /* make it go away again */ + NG_NODE_UNREF(sc->node); /* make it go away again */ return (0); } - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); callout_handle_init(&sc->handle); sc->xmitq.ifq_maxlen = IFQ_MAXLEN; sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN; @@ -3139,13 +3139,13 @@ ngsr_constructor(node_p node) static int ngsr_newhook(node_p node, hook_p hook, const char *name) { - struct sr_softc * sc = node->private; + struct sr_softc * sc = NG_NODE_PRIVATE(node); /* * check if it's our friend the debug hook */ if (strcmp(name, NG_SR_HOOK_DEBUG) == 0) { - hook->private = NULL; /* paranoid */ + NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */ sc->debug_hook = hook; return (0); } @@ -3156,7 +3156,7 @@ ngsr_newhook(node_p node, hook_p hook, const char *name) if (strcmp(name, NG_SR_HOOK_RAW) != 0) { return (EINVAL); } - hook->private = sc; + NG_HOOK_SET_PRIVATE(hook, sc); sc->hook = hook; sc->datahooks++; sr_up(sc); @@ -3176,7 +3176,7 @@ ngsr_rcvmsg(node_p node, item_p item, hook_p lasthook) struct ng_mesg *msg; NGI_GET_MSG(item,msg); - sc = node->private; + sc = NG_NODE_PRIVATE(node); switch (msg->header.typecookie) { case NG_SR_COOKIE: error = EINVAL; @@ -3236,7 +3236,7 @@ ngsr_rcvdata(hook_p hook, item_p item) { int s; int error = 0; - struct sr_softc * sc = hook->node->private; + struct sr_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); struct ifqueue *xmitq_p; struct mbuf *m; meta_p meta; @@ -3247,7 +3247,7 @@ ngsr_rcvdata(hook_p hook, item_p item) /* * data doesn't come in from just anywhere (e.g control hook) */ - if ( hook->private == NULL) { + if ( NG_HOOK_PRIVATE(hook) == NULL) { error = ENETDOWN; goto bad; } @@ -3293,10 +3293,10 @@ bad: static int ngsr_shutdown(node_p node) { - struct sr_softc * sc = node->private; + struct sr_softc * sc = NG_NODE_PRIVATE(node); sr_down(sc); - ng_unref(node); + NG_NODE_UNREF(node); /* XXX should drain queues! */ if (ng_make_node_common(&typestruct, &sc->node) != 0) return (0); @@ -3304,10 +3304,10 @@ ngsr_shutdown(node_p node) if (ng_name_node(sc->node, sc->nodename)) { printf("node naming failed\n"); sc->node = NULL; - ng_unref(sc->node); /* drop it again */ + NG_NODE_UNREF(sc->node); /* drop it again */ return (0); } - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); callout_handle_init(&sc->handle); /* should kill timeout */ sc->running = 0; return (0); @@ -3318,7 +3318,7 @@ static int ngsr_connect(hook_p hook) { /* probably not at splnet, force outward queueing */ - hook->peer->flags |= HK_QUEUE; + NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook)); /* be really amiable and just say "YUP that's OK by me! " */ return (0); } @@ -3337,12 +3337,12 @@ ngsr_connect(hook_p hook) static int ngsr_disconnect(hook_p hook) { - struct sr_softc * sc = hook->node->private; + struct sr_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); int s; /* * If it's the data hook, then free resources etc. */ - if (hook->private) { + if (NG_HOOK_PRIVATE(hook)) { s = splimp(); sc->datahooks--; if (sc->datahooks == 0) diff --git a/sys/dev/sr/if_sr_isa.c b/sys/dev/sr/if_sr_isa.c index a7ba8e9..830b595 100644 --- a/sys/dev/sr/if_sr_isa.c +++ b/sys/dev/sr/if_sr_isa.c @@ -936,10 +936,10 @@ srattach(struct sr_hardc *hc) return (0); sprintf(sc->nodename, "%s%d", NG_SR_NODE_TYPE, sc->unit); if (ng_name_node(sc->node, sc->nodename)) { - ng_unref(sc->node); /* make it go away again */ + NG_NODE_UNREF(sc->node); /* make it go away again */ return (0); } - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); callout_handle_init(&sc->handle); sc->xmitq.ifq_maxlen = IFQ_MAXLEN; sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN; @@ -3139,13 +3139,13 @@ ngsr_constructor(node_p node) static int ngsr_newhook(node_p node, hook_p hook, const char *name) { - struct sr_softc * sc = node->private; + struct sr_softc * sc = NG_NODE_PRIVATE(node); /* * check if it's our friend the debug hook */ if (strcmp(name, NG_SR_HOOK_DEBUG) == 0) { - hook->private = NULL; /* paranoid */ + NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */ sc->debug_hook = hook; return (0); } @@ -3156,7 +3156,7 @@ ngsr_newhook(node_p node, hook_p hook, const char *name) if (strcmp(name, NG_SR_HOOK_RAW) != 0) { return (EINVAL); } - hook->private = sc; + NG_HOOK_SET_PRIVATE(hook, sc); sc->hook = hook; sc->datahooks++; sr_up(sc); @@ -3176,7 +3176,7 @@ ngsr_rcvmsg(node_p node, item_p item, hook_p lasthook) struct ng_mesg *msg; NGI_GET_MSG(item,msg); - sc = node->private; + sc = NG_NODE_PRIVATE(node); switch (msg->header.typecookie) { case NG_SR_COOKIE: error = EINVAL; @@ -3236,7 +3236,7 @@ ngsr_rcvdata(hook_p hook, item_p item) { int s; int error = 0; - struct sr_softc * sc = hook->node->private; + struct sr_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); struct ifqueue *xmitq_p; struct mbuf *m; meta_p meta; @@ -3247,7 +3247,7 @@ ngsr_rcvdata(hook_p hook, item_p item) /* * data doesn't come in from just anywhere (e.g control hook) */ - if ( hook->private == NULL) { + if ( NG_HOOK_PRIVATE(hook) == NULL) { error = ENETDOWN; goto bad; } @@ -3293,10 +3293,10 @@ bad: static int ngsr_shutdown(node_p node) { - struct sr_softc * sc = node->private; + struct sr_softc * sc = NG_NODE_PRIVATE(node); sr_down(sc); - ng_unref(node); + NG_NODE_UNREF(node); /* XXX should drain queues! */ if (ng_make_node_common(&typestruct, &sc->node) != 0) return (0); @@ -3304,10 +3304,10 @@ ngsr_shutdown(node_p node) if (ng_name_node(sc->node, sc->nodename)) { printf("node naming failed\n"); sc->node = NULL; - ng_unref(sc->node); /* drop it again */ + NG_NODE_UNREF(sc->node); /* drop it again */ return (0); } - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); callout_handle_init(&sc->handle); /* should kill timeout */ sc->running = 0; return (0); @@ -3318,7 +3318,7 @@ static int ngsr_connect(hook_p hook) { /* probably not at splnet, force outward queueing */ - hook->peer->flags |= HK_QUEUE; + NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook)); /* be really amiable and just say "YUP that's OK by me! " */ return (0); } @@ -3337,12 +3337,12 @@ ngsr_connect(hook_p hook) static int ngsr_disconnect(hook_p hook) { - struct sr_softc * sc = hook->node->private; + struct sr_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); int s; /* * If it's the data hook, then free resources etc. */ - if (hook->private) { + if (NG_HOOK_PRIVATE(hook)) { s = splimp(); sc->datahooks--; if (sc->datahooks == 0) diff --git a/sys/dev/usb/udbp.c b/sys/dev/usb/udbp.c index 125558b..a7bcac0 100644 --- a/sys/dev/usb/udbp.c +++ b/sys/dev/usb/udbp.c @@ -357,11 +357,11 @@ USB_ATTACH(udbp) char nodename[128]; sprintf(nodename, "%s", USBDEVNAME(sc->sc_dev)); if ((err = ng_name_node(sc->node, nodename))) { - ng_unref(sc->node); + NG_NODE_UNREF(sc->node); sc->node = NULL; goto bad; } else { - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); sc->xmitq.ifq_maxlen = IFQ_MAXLEN; sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN; mtx_init(&sc->xmitq.ifq_mtx, "usb_xmitq", MTX_DEF); @@ -420,10 +420,9 @@ USB_DETACH(udbp) } if (sc->flags & NETGRAPH_INITIALISED) { - ng_unname(sc->node); - ng_udbp_rmnode(sc->node); - sc->node->private = NULL; - ng_unref(sc->node); + ng_rmnode_self(sc->node); + NG_NODE_SET_PRIVATE(sc->node, NULL); + NG_NODE_UNREF(sc->node); sc->node = NULL; /* Paranoid */ } @@ -629,7 +628,7 @@ ng_udbp_constructor(node_p node) Static int ng_udbp_newhook(node_p node, hook_p hook, const char *name) { - const udbp_p sc = node->private; + const udbp_p sc = NG_NODE_PRIVATE(node); #if 0 /* Possibly start up the device if it's not already going */ @@ -640,7 +639,7 @@ ng_udbp_newhook(node_p node, hook_p hook, const char *name) if (strcmp(name, NG_UDBP_HOOK_NAME) == 0) { sc->hook = hook; - hook->private = NULL; + NG_HOOK_SET_PRIVATE(hook, NULL); } else { return (EINVAL); /* not a hook we know about */ } @@ -661,7 +660,7 @@ ng_udbp_newhook(node_p node, hook_p hook, const char *name) Static int ng_udbp_rcvmsg(node_p node, item_p item, hook_p lasthook) { - const udbp_p sc = node->private; + const udbp_p sc = NG_NODE_PRIVATE(node); struct ng_mesg *resp = NULL; int error = 0; struct ng_mesg *msg; @@ -714,7 +713,7 @@ ng_udbp_rcvmsg(node_p node, item_p item, hook_p lasthook) Static int ng_udbp_rcvdata(hook_p hook, item_p item) { - const udbp_p sc = hook->node->private; + const udbp_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); int error; struct ifqueue *xmitq_p; int s; @@ -765,29 +764,37 @@ bad: /* Static int ng_udbp_rmnode(node_p node) { - const udbp_p sc = node->private; + const udbp_p sc = NG_NODE_PRIVATE(node); int err; - node->flags |= NG_INVALID; + if (sc->flags & DISCONNECTED) { + /* + * WE are really going away.. hardware must have gone. + * Assume that the hardware drive part will clear up the + * sc, in fact it may already have done so.. + * In which case we may have just segfaulted..XXX + */ + return (0); + } + /* stolen from attach routine */ /* Drain the queues */ IF_DRAIN(&sc->xmitq_hipri); IF_DRAIN(&sc->xmitq); sc->packets_in = 0; /* reset stats */ sc->packets_out = 0; - ng_unref(node); /* forget it ever existed */ + NG_NODE_UNREF(node); /* forget it ever existed */ - /* stolen from attach routine */ if ((err = ng_make_node_common(&ng_udbp_typestruct, &sc->node)) == 0) { char nodename[128]; sprintf(nodename, "%s", USBDEVNAME(sc->sc_dev)); if ((err = ng_name_node(sc->node, nodename))) { - ng_unref(sc->node); /* out damned spot! */ + NG_NODE_UNREF(sc->node); /* out damned spot! */ sc->flags &= ~NETGRAPH_INITIALISED; sc->node = NULL; } else { - sc->node->private = sc; + NG_NODE_SET_PRIVATE(sc->node, sc); } } return (err); @@ -801,7 +808,7 @@ Static int ng_udbp_connect(hook_p hook) { /* probably not at splnet, force outward queueing */ - hook->peer->flags |= HK_QUEUE; + NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook)); /* be really amiable and just say "YUP that's OK by me! " */ return (0); } @@ -814,12 +821,12 @@ ng_udbp_connect(hook_p hook) Static int ng_udbp_disconnect(hook_p hook) { - const udbp_p sc = hook->node->private; + const udbp_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); sc->hook = NULL; - if ((hook->node->numhooks == 0) - && ((hook->node->flags & NG_INVALID) == 0)) - ng_rmnode_self(hook->node); + if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0) + && (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) + ng_rmnode_self(NG_HOOK_NODE(hook)); return (0); } |