From: Antonio Huete Jimenez Date: Thu, 15 Apr 2010 17:37:19 +0000 (+0200) Subject: if_ath - Properly remove sysctls on detach. X-Git-Tag: v2.7.2~4^2~7 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/09da298d59d41c0312d1677ee1cac382c23106d5 if_ath - Properly remove sysctls on detach. Submitted-by: Johannes Hofmann --- diff --git a/sys/dev/netif/ath/ath/if_ath.c b/sys/dev/netif/ath/ath/if_ath.c index aa83d04170..0001f3fd9b 100644 --- a/sys/dev/netif/ath/ath/if_ath.c +++ b/sys/dev/netif/ath/ath/if_ath.c @@ -372,6 +372,14 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) if_initname(ifp, device_get_name(sc->sc_dev), device_get_unit(sc->sc_dev)); + /* prepare sysctl tree for use in sub modules */ + sysctl_ctx_init(&sc->sc_sysctl_ctx); + sc->sc_sysctl_tree = SYSCTL_ADD_NODE(&sc->sc_sysctl_ctx, + SYSCTL_STATIC_CHILDREN(_hw), + OID_AUTO, + device_get_nameunit(sc->sc_dev), + CTLFLAG_RD, 0, ""); + ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, &status); if (ah == NULL) { if_printf(ifp, "unable to attach hardware; HAL status %u\n", @@ -782,6 +790,10 @@ ath_detach(struct ath_softc *sc) ath_desc_free(sc); ath_tx_cleanup(sc); ath_hal_detach(sc->sc_ah); /* NB: sets chip in full sleep */ + if (sc->sc_sysctl_tree) { + sysctl_ctx_free(&sc->sc_sysctl_ctx); + sc->sc_sysctl_tree = NULL; + } if_free(ifp); return 0; @@ -6552,11 +6564,7 @@ ath_sysctlattach(struct ath_softc *sc) struct ath_hal *ah = sc->sc_ah; ctx = &sc->sc_sysctl_ctx; - sysctl_ctx_init(ctx); - tree = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw), - OID_AUTO, - device_get_nameunit(sc->sc_dev), - CTLFLAG_RD, 0, ""); + tree = sc->sc_sysctl_tree; if (tree == NULL) { device_printf(sc->sc_dev, "can't add sysctl node\n"); return; diff --git a/sys/dev/netif/ath/ath/if_athvar.h b/sys/dev/netif/ath/ath/if_athvar.h index 815dd36265..5b7fac99ca 100644 --- a/sys/dev/netif/ath/ath/if_athvar.h +++ b/sys/dev/netif/ath/ath/if_athvar.h @@ -345,6 +345,7 @@ struct ath_softc { u_int32_t sc_avgtsfdeltap;/* TDMA slot adjust (+) */ u_int32_t sc_avgtsfdeltam;/* TDMA slot adjust (-) */ struct sysctl_ctx_list sc_sysctl_ctx; + struct sysctl_oid *sc_sysctl_tree; }; #define ATH_LOCK_INIT(_sc) \ diff --git a/sys/dev/netif/ath/rate_sample/sample.c b/sys/dev/netif/ath/rate_sample/sample.c index f0df2a2bcd..465ac727ed 100644 --- a/sys/dev/netif/ath/rate_sample/sample.c +++ b/sys/dev/netif/ath/rate_sample/sample.c @@ -953,11 +953,7 @@ ath_rate_sysctlattach(struct ath_softc *sc, struct sample_softc *ssc) struct sysctl_oid *tree; ctx = &sc->sc_sysctl_ctx; - sysctl_ctx_init(ctx); - tree = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw), - OID_AUTO, - device_get_nameunit(sc->sc_dev), - CTLFLAG_RD, 0, ""); + tree = sc->sc_sysctl_tree; if (tree == NULL) { device_printf(sc->sc_dev, "can't add sysctl node\n"); return;