diff mbox

[v2,1/4] mt76: introduce mt76_{incr,decr} utility routines

Message ID 2a49ca8370e2b582941b073f00438066f7ffa212.1530260731.git.lorenzo.bianconi@redhat.com (mailing list archive)
State Accepted
Commit ee8aa945e4ae94f2928ef1c2af340a655f16dfcc
Delegated to: Kalle Valo
Headers show

Commit Message

Lorenzo Bianconi June 29, 2018, 11:40 a.m. UTC
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>
---
 drivers/net/wireless/mediatek/mt76/mt76.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Kalle Valo July 4, 2018, 3:16 p.m. UTC | #1
Lorenzo Bianconi <lorenzo.bianconi@redhat.com> wrote:

> 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>

4 patches applied to wireless-drivers-next.git, thanks.

ee8aa945e4ae mt76: introduce mt76_{incr,decr} utility routines
1fc9bc9ab501 mt76x2: dfs: add sw event ring buffer
b7384e4e0d56 mt76x2: dfs: add sw pattern detector
4a07ed51cae1 mt76x2: debugfs: add sw pulse statistics to dfs debugfs
diff mbox

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index d2166fbf50ff..96e9798bb8a0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -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)
 {