mt76: introduce mt76_{incr,decr} utility routines
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Fri, 29 Jun 2018 11:40:52 +0000 (13:40 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Wed, 4 Jul 2018 15:15:57 +0000 (18:15 +0300)
Add mt76_{incr,decr} utility routines to increment/decrement a value
with wrap-around (they will be used by mt76x2 DFS sw detector)

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mediatek/mt76/mt76.h

index d2166fbf50ff3b561439f5a2a19eb54f6911887a..96e9798bb8a02e549bfed971198b8fa98d064d8f 100644 (file)
@@ -390,6 +390,18 @@ struct dentry *mt76_register_debugfs(struct mt76_dev *dev);
 int mt76_eeprom_init(struct mt76_dev *dev, int len);
 void mt76_eeprom_override(struct mt76_dev *dev);
 
+/* increment with wrap-around */
+static inline int mt76_incr(int val, int size)
+{
+       return (val + 1) & (size - 1);
+}
+
+/* decrement with wrap-around */
+static inline int mt76_decr(int val, int size)
+{
+       return (val - 1) & (size - 1);
+}
+
 static inline struct ieee80211_txq *
 mtxq_to_txq(struct mt76_txq *mtxq)
 {