From patchwork Fri Jun 29 11:40:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10496437 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 1657F6022E for ; Fri, 29 Jun 2018 11:41:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 052D129762 for ; Fri, 29 Jun 2018 11:41:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC17F2976E; Fri, 29 Jun 2018 11:41:08 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 9A8BC29762 for ; Fri, 29 Jun 2018 11:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935698AbeF2LlH (ORCPT ); Fri, 29 Jun 2018 07:41:07 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:39183 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935727AbeF2LlF (ORCPT ); Fri, 29 Jun 2018 07:41:05 -0400 Received: by mail-wr0-f195.google.com with SMTP id b8-v6so8537705wro.6 for ; Fri, 29 Jun 2018 04:41:05 -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:in-reply-to :references; bh=g1Z6oevHPGPdp+VYVJIJZJxKxzonMNBwvdtGRb9Xv8M=; b=Pq4bdu0PsQbJP+hm4vTnWTqjSW1nDhJlGgcKa1L8zAEgu3Nbu4A/CAaVt03PErZAgg AObgRJQhEhJZTWK153nTG8LFKbuhrAsXV4sZPNtrTOKsldN+g9ceOFR54roAJhQjKQhU w3/aQ/jC3QNtyO1qC8ABYgA4Th9+DZ6GwmvGMuJEAtKChh0XEbS/WfAv34DDy14GwqPN QOY0bl03r+xbw/Ejcdaecx3Az31iQtjpViO6m6yPfa7ETT2Xcg9cDB6SMkVumlcgid8Z fFmRnzNRD17shFy9qEU/FdANYLi1/sxYRiQW5FdIIiUakVwM9XfIeBkKD3rh4G2DlXTp hYMQ== X-Gm-Message-State: APt69E1B1O+fJ2YoMuXn2VgCHlIugrQwp9SW8dG0Y6uCq/eAz3lSFwxW bdRDEiwwuzd6DNGaG5guEvy8tg== X-Google-Smtp-Source: AAOMgpdcgAcCn5DnJShxfKhKaVzxXCytWuH9zCWexkGf88fYHbAUnEpqfF1qBQAyaPgmrKOAdbSpVQ== X-Received: by 2002:a5d:478d:: with SMTP id w13-v6mr11243159wrq.188.1530272464345; Fri, 29 Jun 2018 04:41:04 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id s3-v6sm10242225wrp.76.2018.06.29.04.41.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Jun 2018 04:41:03 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, kvalo@codeaurora.org Subject: [PATCH v2 1/4] mt76: introduce mt76_{incr,decr} utility routines Date: Fri, 29 Jun 2018 13:40:52 +0200 Message-Id: <2a49ca8370e2b582941b073f00438066f7ffa212.1530260731.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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) {