Commit 1920a0cc authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt76x02: introduce mt76x02_pre_tbtt_enable and mt76x02_beacon_enable macros

Improve code readability introducing mt76x02_pre_tbtt_enable and
mt76x02_beacon_enable utility macros
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 49de79ad
...@@ -14,7 +14,7 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef) ...@@ -14,7 +14,7 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)
int ret; int ret;
cancel_delayed_work_sync(&dev->cal_work); cancel_delayed_work_sync(&dev->cal_work);
dev->beacon_ops->pre_tbtt_enable(dev, false); mt76x02_pre_tbtt_enable(dev, false);
if (mt76_is_mmio(dev)) if (mt76_is_mmio(dev))
tasklet_disable(&dev->dfs_pd.dfs_tasklet); tasklet_disable(&dev->dfs_pd.dfs_tasklet);
...@@ -31,7 +31,7 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef) ...@@ -31,7 +31,7 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)
mt76x02_dfs_init_params(dev); mt76x02_dfs_init_params(dev);
tasklet_enable(&dev->dfs_pd.dfs_tasklet); tasklet_enable(&dev->dfs_pd.dfs_tasklet);
} }
dev->beacon_ops->pre_tbtt_enable(dev, true); mt76x02_pre_tbtt_enable(dev, true);
mt76_txq_schedule_all(&dev->mt76); mt76_txq_schedule_all(&dev->mt76);
......
...@@ -64,6 +64,11 @@ struct mt76x02_beacon_ops { ...@@ -64,6 +64,11 @@ struct mt76x02_beacon_ops {
void (*beacon_enable)(struct mt76x02_dev *dev, bool en); void (*beacon_enable)(struct mt76x02_dev *dev, bool en);
}; };
#define mt76x02_beacon_enable(dev, enable) \
(dev)->beacon_ops->beacon_enable(dev, enable)
#define mt76x02_pre_tbtt_enable(dev, enable) \
(dev)->beacon_ops->pre_tbtt_enable(dev, enable)
struct mt76x02_dev { struct mt76x02_dev {
struct mt76_dev mt76; /* must be first */ struct mt76_dev mt76; /* must be first */
......
...@@ -130,8 +130,7 @@ __mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx, ...@@ -130,8 +130,7 @@ __mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx,
MT_BEACON_TIME_CFG_TBTT_EN | MT_BEACON_TIME_CFG_TBTT_EN |
MT_BEACON_TIME_CFG_TIMER_EN; MT_BEACON_TIME_CFG_TIMER_EN;
mt76_rmw(dev, MT_BEACON_TIME_CFG, reg, reg * en); mt76_rmw(dev, MT_BEACON_TIME_CFG, reg, reg * en);
mt76x02_beacon_enable(dev, en);
dev->beacon_ops->beacon_enable(dev, en);
} }
void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev,
...@@ -140,7 +139,7 @@ void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, ...@@ -140,7 +139,7 @@ void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev,
u8 vif_idx = ((struct mt76x02_vif *)vif->drv_priv)->idx; u8 vif_idx = ((struct mt76x02_vif *)vif->drv_priv)->idx;
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
dev->beacon_ops->pre_tbtt_enable(dev, false); mt76x02_pre_tbtt_enable(dev, false);
if (mt76_is_usb(dev)) if (mt76_is_usb(dev))
skb = ieee80211_beacon_get(mt76_hw(dev), vif); skb = ieee80211_beacon_get(mt76_hw(dev), vif);
...@@ -150,7 +149,7 @@ void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, ...@@ -150,7 +149,7 @@ void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev,
__mt76x02_mac_set_beacon_enable(dev, vif_idx, val, skb); __mt76x02_mac_set_beacon_enable(dev, vif_idx, val, skb);
dev->beacon_ops->pre_tbtt_enable(dev, true); mt76x02_pre_tbtt_enable(dev, true);
} }
void void
......
...@@ -37,7 +37,7 @@ mt76x2u_set_channel(struct mt76x02_dev *dev, ...@@ -37,7 +37,7 @@ mt76x2u_set_channel(struct mt76x02_dev *dev,
int err; int err;
cancel_delayed_work_sync(&dev->cal_work); cancel_delayed_work_sync(&dev->cal_work);
dev->beacon_ops->pre_tbtt_enable(dev, false); mt76x02_pre_tbtt_enable(dev, false);
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
set_bit(MT76_RESET, &dev->mt76.state); set_bit(MT76_RESET, &dev->mt76.state);
...@@ -53,7 +53,7 @@ mt76x2u_set_channel(struct mt76x02_dev *dev, ...@@ -53,7 +53,7 @@ mt76x2u_set_channel(struct mt76x02_dev *dev,
clear_bit(MT76_RESET, &dev->mt76.state); clear_bit(MT76_RESET, &dev->mt76.state);
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
dev->beacon_ops->pre_tbtt_enable(dev, true); mt76x02_pre_tbtt_enable(dev, true);
mt76_txq_schedule_all(&dev->mt76); mt76_txq_schedule_all(&dev->mt76);
return err; return err;
......
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