iPXE
ath9k_common.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009-2011 Atheros Communications Inc.
00003  *
00004  * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
00005  * Original from Linux kernel 3.0.1
00006  *
00007  * Permission to use, copy, modify, and/or distribute this software for any
00008  * purpose with or without fee is hereby granted, provided that the above
00009  * copyright notice and this permission notice appear in all copies.
00010  *
00011  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00012  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00013  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
00014  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00015  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00016  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00017  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00018  */
00019 
00020 /*
00021  * Module for common driver code between ath9k and ath9k_htc
00022  */
00023 
00024 #include "common.h"
00025 
00026 /*
00027  * Update internal channel flags.
00028  */
00029 void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
00030                                struct net80211_channel *chan)
00031 {
00032         ichan->channel = chan->center_freq;
00033         ichan->chan = chan;
00034 
00035         if (chan->band == NET80211_BAND_2GHZ) {
00036                 ichan->chanmode = CHANNEL_G;
00037                 ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM;
00038         } else {
00039                 ichan->chanmode = CHANNEL_A;
00040                 ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
00041         }
00042 }
00043 
00044 /*
00045  * Get the internal channel reference.
00046  */
00047 struct ath9k_channel *ath9k_cmn_get_curchannel(struct net80211_device *dev,
00048                                                struct ath_hw *ah)
00049 {
00050         struct net80211_channel *curchan = dev->channels + dev->channel;
00051         struct ath9k_channel *channel;
00052         u8 chan_idx;
00053 
00054         chan_idx = curchan->hw_value;
00055         channel = &ah->channels[chan_idx];
00056         ath9k_cmn_update_ichannel(channel, curchan);
00057 
00058         return channel;
00059 }
00060 
00061 void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow,
00062                             u16 new_txpow, u16 *txpower)
00063 {
00064         if (cur_txpow != new_txpow) {
00065                 ath9k_hw_set_txpowerlimit(ah, new_txpow, 0);
00066                 /* read back in case value is clamped */
00067                 *txpower = ath9k_hw_regulatory(ah)->power_limit;
00068         }
00069 }