Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp657680imm; Fri, 29 Jun 2018 04:21:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIvZKsgvfDv087NMaQHpXcGrhqril7sGsGbEk7DgXbRndLOAz+FitguGR6cKnr0TkfTU+77 X-Received: by 2002:a65:6094:: with SMTP id t20-v6mr12440519pgu.264.1530271266132; Fri, 29 Jun 2018 04:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530271266; cv=none; d=google.com; s=arc-20160816; b=umMm11sWDJQFt2hB6nobu18y4fSCJsYBFn5epf4ptLT+u8ARLAitFt0wTvklKCS0Bm rqACocvWCGTsRWEp+XD9KifQ4OiaAK0YWHEcikDPFTl/tv9drRsP08Ag9IVXB4D3fROy rFP0aBh7nk5C/G7wQthdDBFLdBy/NI+vyOIXmbCRX2YBJAsFKxBp1p3lMPQlmDiP9A00 KTBUGP+yxt2jxd/3fc+I621RuZpjdCiM7GsYLJvT89ATAaqbtf5T29FAO5ybs8CpuPJn eJSZfCEe8x/AGuKwBqbnbOQg9qqUwdRAi1F648FV6MgWiFCxI2Qu8sEVZMrbbiLRPjOi SmPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=bC4fT6RuVoGfYoDbLl/VRQac+nJfLJEiwSwyPa8xgFQ=; b=DgRl4eFMp3/TmL2bA5uH+k1TH1jC/fN3wB5mTlvc90bN0/yjjNIFOgBxHfFbCvqlMg UcKuQmU/TACI05fsKT8gZhLh5ccXrvCkrDJRzcN4A9wlcHXvnKav9rGn5UWlF6ssf0NM z7EToU6lC2OgxCTmUofGur7/GJSzE1eP3HmbomEbumN4JFSE8ri/UoNVmy6NfdKdgllL MvBWALw+CRw/4Eo9ISz9k3Rs+w9nRuR1qdrrlhDem9A/hG2mV/M/g+HwADHljcFwquDW U8aBp3MYIQLvSy4yPzrIZKwbSyopsqupULGGh1e/lTRJGm5fU6uXToChaFYTI0wfAayF NnUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9-v6si8591010pla.377.2018.06.29.04.20.51; Fri, 29 Jun 2018 04:21:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755043AbeF2Kyq (ORCPT + 99 others); Fri, 29 Jun 2018 06:54:46 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:49183 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1755002AbeF2Kyo (ORCPT ); Fri, 29 Jun 2018 06:54:44 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0DF0AD2192A12; Fri, 29 Jun 2018 18:54:37 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.382.0; Fri, 29 Jun 2018 18:51:23 +0800 From: Peng Li To: CC: , , , , , Subject: [PATCH net-next 05/10] net: hns3: using modulo for cyclic counters in hclge_cmd_send Date: Fri, 29 Jun 2018 19:23:00 +0800 Message-ID: <1530271385-49668-6-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530271385-49668-1-git-send-email-lipeng321@huawei.com> References: <1530271385-49668-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huazhong Tan There are some codes in hclge_cmd.c which can be simplified by used %= operator. Signed-off-by: Huazhong Tan Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c index 0839e84..28556a9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c @@ -228,8 +228,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num) desc_to_use = &hw->cmq.csq.desc[hw->cmq.csq.next_to_use]; *desc_to_use = desc[handle]; (hw->cmq.csq.next_to_use)++; - if (hw->cmq.csq.next_to_use == hw->cmq.csq.desc_num) - hw->cmq.csq.next_to_use = 0; + hw->cmq.csq.next_to_use %= hw->cmq.csq.desc_num; handle++; } @@ -269,8 +268,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num) hw->cmq.last_status = desc_ret; ntc++; handle++; - if (ntc == hw->cmq.csq.desc_num) - ntc = 0; + ntc %= hw->cmq.csq.desc_num; } } -- 1.9.1