Index: sys/dev/bwn/if_bwn.c =================================================================== --- sys/dev/bwn/if_bwn.c +++ sys/dev/bwn/if_bwn.c @@ -128,7 +128,11 @@ static int bwn_attach_core(struct bwn_mac *); static int bwn_phy_getinfo(struct bwn_mac *, int); static int bwn_chiptest(struct bwn_mac *); +static void bwn_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel []); static int bwn_setup_channels(struct bwn_mac *, int, int); +static void bwn_add_channels(struct bwn_mac *, int, int *, + struct ieee80211_channel []); static void bwn_shm_ctlword(struct bwn_mac *, uint16_t, uint16_t); static void bwn_addchannels(struct ieee80211_channel [], int, int *, @@ -679,6 +683,7 @@ ic->ic_headroom = sizeof(struct bwn_txhdr); /* override default methods */ + ic->ic_getradiocaps = bwn_getradiocaps; ic->ic_raw_xmit = bwn_raw_xmit; ic->ic_updateslot = bwn_updateslot; ic->ic_update_promisc = bwn_update_promisc; @@ -1494,12 +1499,21 @@ return (ENODEV); } +static void +bwn_getradiocaps(struct ieee80211com *ic, int maxchans, int *nchans, + struct ieee80211_channel chans[]) +{ + struct bwn_softc *sc = ic->ic_softc; + struct bwn_mac *mac = sc->sc_curmac; + + bwn_add_channels(mac, maxchans, nchans, chans); +} + static int bwn_setup_channels(struct bwn_mac *mac, int have_bg, int have_a) { struct bwn_softc *sc = mac->mac_sc; struct ieee80211com *ic = &sc->sc_ic; - uint8_t bands[IEEE80211_MODE_BYTES]; memset(ic->ic_channels, 0, sizeof(ic->ic_channels)); ic->ic_nchans = 0; @@ -1509,25 +1523,35 @@ have_bg, have_a); - if (have_bg) { + mac->mac_phy.supports_2ghz = have_bg; + mac->mac_phy.supports_5ghz = have_a; + + bwn_add_channels(mac, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); + + return (ic->ic_nchans == 0 ? ENXIO : 0); +} + +static void +bwn_add_channels(struct bwn_mac *mac, int maxchans, int *nchans, + struct ieee80211_channel chans[]) +{ + uint8_t bands[IEEE80211_MODE_BYTES]; + + if (mac->mac_phy.supports_2ghz) { memset(bands, 0, sizeof(bands)); setbit(bands, IEEE80211_MODE_11B); setbit(bands, IEEE80211_MODE_11G); - bwn_addchannels(ic->ic_channels, IEEE80211_CHAN_MAX, - &ic->ic_nchans, &bwn_chantable_bg, bands); + bwn_addchannels(chans, maxchans, nchans, &bwn_chantable_bg, + bands); } - if (have_a) { + if (mac->mac_phy.supports_5ghz) { memset(bands, 0, sizeof(bands)); setbit(bands, IEEE80211_MODE_11A); - bwn_addchannels(ic->ic_channels, IEEE80211_CHAN_MAX, - &ic->ic_nchans, &bwn_chantable_a, bands); + bwn_addchannels(chans, maxchans, nchans, &bwn_chantable_a, + bands); } - - mac->mac_phy.supports_2ghz = have_bg; - mac->mac_phy.supports_5ghz = have_a; - - return (ic->ic_nchans == 0 ? ENXIO : 0); } uint32_t