static void set_channel(struct net_device *netdev, u8 channel) { struct zd_mac *mac = zd_netdev_mac(netdev); dev_dbg_f(zd_mac_dev(mac), "channel %d\n", channel); zd_chip_set_channel(&mac->chip, channel); }
int zd_mac_open(struct net_device *netdev) { struct zd_mac *mac = zd_netdev_mac(netdev); struct zd_chip *chip = &mac->chip; int r; tasklet_enable(&mac->rx_tasklet); r = zd_chip_enable_int(chip); if (r < 0) goto out; r = zd_chip_set_basic_rates(chip, CR_RATES_80211B | CR_RATES_80211G); if (r < 0) goto disable_int; r = reset_mode(mac); if (r) goto disable_int; r = zd_chip_switch_radio_on(chip); if (r < 0) goto disable_int; r = zd_chip_set_channel(chip, mac->requested_channel); if (r < 0) goto disable_radio; r = zd_chip_enable_rx(chip); if (r < 0) goto disable_radio; r = zd_chip_enable_hwint(chip); if (r < 0) goto disable_rx; housekeeping_enable(mac); ieee80211softmac_start(netdev); return 0; disable_rx: zd_chip_disable_rx(chip); disable_radio: zd_chip_switch_radio_off(chip); disable_int: zd_chip_disable_int(chip); out: return r; }
int zd_mac_request_channel(struct zd_mac *mac, u8 channel) { unsigned long lock_flags; struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); if (ieee->iw_mode == IW_MODE_INFRA) return -EPERM; spin_lock_irqsave(&mac->lock, lock_flags); if (!zd_regdomain_supports_channel(mac->regdomain, channel)) { spin_unlock_irqrestore(&mac->lock, lock_flags); return -EINVAL; } mac->requested_channel = channel; spin_unlock_irqrestore(&mac->lock, lock_flags); if (netif_running(mac->netdev)) return zd_chip_set_channel(&mac->chip, channel); else return 0; }
static int zd_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) { struct zd_mac *mac = zd_hw_mac(hw); return zd_chip_set_channel(&mac->chip, conf->channel); }