Skip to content

Commit

Permalink
mt76: move mt76x02_get_txpower in mt76x02_util.c
Browse files Browse the repository at this point in the history
Move mt76x02_get_txpower utility routine in mt76x02-lib module
in order to be reused by mt76x0 and mt76x2u drivers

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Oct 23, 2018
1 parent acd4c99 commit 2d736cf
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions mt76x0/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static const struct ieee80211_ops mt76x0e_ops = {
.sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
.wake_tx_queue = mt76_wake_tx_queue,
.get_survey = mt76_get_survey,
.get_txpower = mt76x02_get_txpower,
};

static int mt76x0e_register_device(struct mt76x02_dev *dev)
Expand Down
1 change: 1 addition & 0 deletions mt76x0/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ static const struct ieee80211_ops mt76x0u_ops = {
.sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
.set_rts_threshold = mt76x0_set_rts_threshold,
.wake_tx_queue = mt76_wake_tx_queue,
.get_txpower = mt76x02_get_txpower,
};

static int mt76x0u_register_device(struct mt76x02_dev *dev)
Expand Down
2 changes: 2 additions & 0 deletions mt76x02.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ void mt76x02_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
const u8 *mac);
void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
struct ieee80211_vif *vif);
int mt76x02_get_txpower(struct ieee80211_hw *hw,
struct ieee80211_vif *vif, int *dbm);

extern const u16 mt76x02_beacon_offsets[16];
void mt76x02_set_beacon_offsets(struct mt76x02_dev *dev);
Expand Down
18 changes: 18 additions & 0 deletions mt76x02_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,24 @@ void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
}
EXPORT_SYMBOL_GPL(mt76x02_sw_scan_complete);

int mt76x02_get_txpower(struct ieee80211_hw *hw,
struct ieee80211_vif *vif, int *dbm)
{
struct mt76x02_dev *dev = hw->priv;
u8 nstreams = dev->mt76.chainmask & 0xf;

*dbm = dev->mt76.txpower_cur / 2;

/* convert from per-chain power to combined
* output on 2x2 devices
*/
if (nstreams > 1)
*dbm += 3;

return 0;
}
EXPORT_SYMBOL_GPL(mt76x02_get_txpower);

const u16 mt76x02_beacon_offsets[16] = {
/* 1024 byte per beacon */
0xc000,
Expand Down
15 changes: 1 addition & 14 deletions mt76x2/pci_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,6 @@ mt76x2_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
{
}

static int
mt76x2_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif, int *dbm)
{
struct mt76x02_dev *dev = hw->priv;

*dbm = dev->mt76.txpower_cur / 2;

/* convert from per-chain power to combined output on 2x2 devices */
*dbm += 3;

return 0;
}

static void mt76x2_set_coverage_class(struct ieee80211_hw *hw,
s16 coverage_class)
{
Expand Down Expand Up @@ -277,7 +264,7 @@ const struct ieee80211_ops mt76x2_ops = {
.sw_scan_complete = mt76x02_sw_scan_complete,
.flush = mt76x2_flush,
.ampdu_action = mt76x02_ampdu_action,
.get_txpower = mt76x2_get_txpower,
.get_txpower = mt76x02_get_txpower,
.wake_tx_queue = mt76_wake_tx_queue,
.sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
.release_buffered_frames = mt76_release_buffered_frames,
Expand Down
1 change: 1 addition & 0 deletions mt76x2/usb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,5 @@ const struct ieee80211_ops mt76x2u_ops = {
.sw_scan_start = mt76x02_sw_scan,
.sw_scan_complete = mt76x02_sw_scan_complete,
.sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
.get_txpower = mt76x02_get_txpower,
};

0 comments on commit 2d736cf

Please sign in to comment.