Commit 61c51a74 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: use mt76_dev in mt76_is_{mmio,usb}

Convert mt76_is_mmio and mt76_is_usb to rely on mt76_dev instead of
mt76x02_dev since this is a property not strictly related to hw chipset
and it will be more reusable
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent cc53b52d
...@@ -49,8 +49,8 @@ struct mt76_bus_ops { ...@@ -49,8 +49,8 @@ struct mt76_bus_ops {
enum mt76_bus_type type; enum mt76_bus_type type;
}; };
#define mt76_is_usb(dev) ((dev)->mt76.bus->type == MT76_BUS_USB) #define mt76_is_usb(dev) ((dev)->bus->type == MT76_BUS_USB)
#define mt76_is_mmio(dev) ((dev)->mt76.bus->type == MT76_BUS_MMIO) #define mt76_is_mmio(dev) ((dev)->bus->type == MT76_BUS_MMIO)
enum mt76_txq_id { enum mt76_txq_id {
MT_TXQ_VO = IEEE80211_AC_VO, MT_TXQ_VO = IEEE80211_AC_VO,
......
...@@ -13,7 +13,7 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef) ...@@ -13,7 +13,7 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)
{ {
cancel_delayed_work_sync(&dev->cal_work); cancel_delayed_work_sync(&dev->cal_work);
mt76x02_pre_tbtt_enable(dev, false); mt76x02_pre_tbtt_enable(dev, false);
if (mt76_is_mmio(dev)) if (mt76_is_mmio(&dev->mt76))
tasklet_disable(&dev->dfs_pd.dfs_tasklet); tasklet_disable(&dev->dfs_pd.dfs_tasklet);
mt76_set_channel(&dev->mt76); mt76_set_channel(&dev->mt76);
...@@ -22,7 +22,7 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef) ...@@ -22,7 +22,7 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)
mt76x02_mac_cc_reset(dev); mt76x02_mac_cc_reset(dev);
mt76x02_edcca_init(dev); mt76x02_edcca_init(dev);
if (mt76_is_mmio(dev)) { if (mt76_is_mmio(&dev->mt76)) {
mt76x02_dfs_init_params(dev); mt76x02_dfs_init_params(dev);
tasklet_enable(&dev->dfs_pd.dfs_tasklet); tasklet_enable(&dev->dfs_pd.dfs_tasklet);
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
static inline bool is_mt7610e(struct mt76x02_dev *dev) static inline bool is_mt7610e(struct mt76x02_dev *dev)
{ {
if (!mt76_is_mmio(dev)) if (!mt76_is_mmio(&dev->mt76))
return false; return false;
return mt76_chip(&dev->mt76) == 0x7610; return mt76_chip(&dev->mt76) == 0x7610;
......
...@@ -102,7 +102,7 @@ static int mt76x0_rf_csr_rr(struct mt76x02_dev *dev, u32 offset) ...@@ -102,7 +102,7 @@ static int mt76x0_rf_csr_rr(struct mt76x02_dev *dev, u32 offset)
static int static int
mt76x0_rf_wr(struct mt76x02_dev *dev, u32 offset, u8 val) mt76x0_rf_wr(struct mt76x02_dev *dev, u32 offset, u8 val)
{ {
if (mt76_is_usb(dev)) { if (mt76_is_usb(&dev->mt76)) {
struct mt76_reg_pair pair = { struct mt76_reg_pair pair = {
.reg = offset, .reg = offset,
.value = val, .value = val,
...@@ -121,7 +121,7 @@ static int mt76x0_rf_rr(struct mt76x02_dev *dev, u32 offset) ...@@ -121,7 +121,7 @@ static int mt76x0_rf_rr(struct mt76x02_dev *dev, u32 offset)
int ret; int ret;
u32 val; u32 val;
if (mt76_is_usb(dev)) { if (mt76_is_usb(&dev->mt76)) {
struct mt76_reg_pair pair = { struct mt76_reg_pair pair = {
.reg = offset, .reg = offset,
}; };
...@@ -176,7 +176,7 @@ mt76x0_phy_rf_csr_wr_rp(struct mt76x02_dev *dev, ...@@ -176,7 +176,7 @@ mt76x0_phy_rf_csr_wr_rp(struct mt76x02_dev *dev,
} }
#define RF_RANDOM_WRITE(dev, tab) do { \ #define RF_RANDOM_WRITE(dev, tab) do { \
if (mt76_is_mmio(dev)) \ if (mt76_is_mmio(&dev->mt76)) \
mt76x0_phy_rf_csr_wr_rp(dev, tab, ARRAY_SIZE(tab)); \ mt76x0_phy_rf_csr_wr_rp(dev, tab, ARRAY_SIZE(tab)); \
else \ else \
mt76_wr_rp(dev, MT_MCU_MEMMAP_RF, tab, ARRAY_SIZE(tab));\ mt76_wr_rp(dev, MT_MCU_MEMMAP_RF, tab, ARRAY_SIZE(tab));\
...@@ -744,7 +744,7 @@ mt76x0_phy_get_delta_power(struct mt76x02_dev *dev, u8 tx_mode, ...@@ -744,7 +744,7 @@ mt76x0_phy_get_delta_power(struct mt76x02_dev *dev, u8 tx_mode,
if (!tx_mode) { if (!tx_mode) {
data = mt76_rr(dev, MT_BBP(CORE, 1)); data = mt76_rr(dev, MT_BBP(CORE, 1));
if (is_mt7630(dev) && mt76_is_mmio(dev)) { if (is_mt7630(dev) && mt76_is_mmio(&dev->mt76)) {
int offset; int offset;
/* 2.3 * 8192 or 1.5 * 8192 */ /* 2.3 * 8192 or 1.5 * 8192 */
...@@ -966,7 +966,7 @@ void mt76x0_phy_set_channel(struct mt76x02_dev *dev, ...@@ -966,7 +966,7 @@ void mt76x0_phy_set_channel(struct mt76x02_dev *dev,
break; break;
} }
if (mt76_is_usb(dev)) { if (mt76_is_usb(&dev->mt76)) {
mt76x0_phy_bbp_set_bw(dev, chandef->width); mt76x0_phy_bbp_set_bw(dev, chandef->width);
} else { } else {
if (chandef->width == NL80211_CHAN_WIDTH_80 || if (chandef->width == NL80211_CHAN_WIDTH_80 ||
...@@ -1122,7 +1122,7 @@ static void mt76x0_rf_patch_reg_array(struct mt76x02_dev *dev, ...@@ -1122,7 +1122,7 @@ static void mt76x0_rf_patch_reg_array(struct mt76x02_dev *dev,
switch (reg) { switch (reg) {
case MT_RF(0, 3): case MT_RF(0, 3):
if (mt76_is_mmio(dev)) { if (mt76_is_mmio(&dev->mt76)) {
if (is_mt7630(dev)) if (is_mt7630(dev))
val = 0x70; val = 0x70;
else else
......
...@@ -114,7 +114,7 @@ int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, u32 param) ...@@ -114,7 +114,7 @@ int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, u32 param)
.id = cpu_to_le32(type), .id = cpu_to_le32(type),
.value = cpu_to_le32(param), .value = cpu_to_le32(param),
}; };
bool is_mt76x2e = mt76_is_mmio(dev) && is_mt76x2(dev); bool is_mt76x2e = mt76_is_mmio(&dev->mt76) && is_mt76x2(dev);
int ret; int ret;
if (is_mt76x2e) if (is_mt76x2e)
......
...@@ -161,7 +161,7 @@ void mt76x02_init_device(struct mt76x02_dev *dev) ...@@ -161,7 +161,7 @@ void mt76x02_init_device(struct mt76x02_dev *dev)
#endif #endif
BIT(NL80211_IFTYPE_ADHOC); BIT(NL80211_IFTYPE_ADHOC);
if (mt76_is_usb(dev)) { if (mt76_is_usb(&dev->mt76)) {
hw->extra_tx_headroom += sizeof(struct mt76x02_txwi) + hw->extra_tx_headroom += sizeof(struct mt76x02_txwi) +
MT_DMA_HDR_LEN; MT_DMA_HDR_LEN;
wiphy->iface_combinations = mt76x02u_if_comb; wiphy->iface_combinations = mt76x02u_if_comb;
...@@ -445,7 +445,7 @@ int mt76x02_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -445,7 +445,7 @@ int mt76x02_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
* data registers and sent via HW beacons engine, they require to * data registers and sent via HW beacons engine, they require to
* be already encrypted. * be already encrypted.
*/ */
if (mt76_is_usb(dev) && if (mt76_is_usb(&dev->mt76) &&
vif->type == NL80211_IFTYPE_AP && vif->type == NL80211_IFTYPE_AP &&
!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -626,7 +626,7 @@ void mt76x02_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, ...@@ -626,7 +626,7 @@ void mt76x02_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta,
int idx = msta->wcid.idx; int idx = msta->wcid.idx;
mt76_stop_tx_queues(&dev->mt76, sta, true); mt76_stop_tx_queues(&dev->mt76, sta, true);
if (mt76_is_mmio(dev)) if (mt76_is_mmio(mdev))
mt76x02_mac_wcid_set_drop(dev, idx, ps); mt76x02_mac_wcid_set_drop(dev, idx, ps);
} }
EXPORT_SYMBOL_GPL(mt76x02_sta_ps); EXPORT_SYMBOL_GPL(mt76x02_sta_ps);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment