From patchwork Sat Jun 16 15:56:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10467977 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37411600CC for ; Sat, 16 Jun 2018 15:56:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2536D28BB0 for ; Sat, 16 Jun 2018 15:56:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1967728CE9; Sat, 16 Jun 2018 15:56:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_WEB autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4BF828BB0 for ; Sat, 16 Jun 2018 15:56:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932418AbeFPP4f (ORCPT ); Sat, 16 Jun 2018 11:56:35 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:37337 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756879AbeFPP4e (ORCPT ); Sat, 16 Jun 2018 11:56:34 -0400 Received: by mail-wm0-f68.google.com with SMTP id r125-v6so8513568wmg.2 for ; Sat, 16 Jun 2018 08:56:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=g1Z6oevHPGPdp+VYVJIJZJxKxzonMNBwvdtGRb9Xv8M=; b=t3zQZuZ8Dzk45zx0yb4VKCYfQC7H/QtNhbnAPOJYCDTQFKb8L/jjXU73AodUSHrORP /g3SOtTlVNpjdyy44ZVoiWFUuqPPTqX1B8t+QRMMjamX+xHm+XKsCJPHh6NEr/0LQmEP NAkBJyvFcfmBVI9o063/b1micEtqqoEIn/6hgIRLNGwX6RYOrYpv6ziP13QVeKFiFoTl 1uI3gvStFL1SeYWA/a5azSVR02K4LTcLALQ46iDNtiGZQ4gBswCpuEbZCw88bAA8sGyD lGcXGalFwUSPgTb/3fCJdqq7kaNu+3BvWJUCTtuaAKNVzk+EkjQQFsfPG43FJfZaippO NbWg== X-Gm-Message-State: APt69E1aZqAa3LOcmz/JuWm4oiFifENd1EUkCJs74pt5pBXV9a2uM5sa Yys1RyDIzBV3tYuXrqtzpHdtvFmqJNc= X-Google-Smtp-Source: ADUXVKLzoy65PVoLi3Ds38qwYMM83IdrNTbbroSJ1iHWp7kbDz1e4X1vOsZY1fBrlwdhpLnCB6yFuA== X-Received: by 2002:a1c:9c4c:: with SMTP id f73-v6mr3979867wme.141.1529164592993; Sat, 16 Jun 2018 08:56:32 -0700 (PDT) Received: from localhost.localdomain ([151.66.6.110]) by smtp.gmail.com with ESMTPSA id j131-v6sm7442153wmg.24.2018.06.16.08.56.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Jun 2018 08:56:32 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org Subject: [PATCH 1/4] mt76: introduce mt76_{incr,decr} utility routines Date: Sat, 16 Jun 2018 17:56:18 +0200 Message-Id: <20180616155621.30539-2-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.17.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/net/wireless/mediatek/mt76/mt76.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) {