Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4610670ybe; Mon, 16 Sep 2019 15:27:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwz6fD5qj1yxOrQUQSfxSf7sCJJOlQH8cu/UP3rZQPAk0eMv9DOMgy1FTS3oVC2t/mTJflt X-Received: by 2002:a05:6402:2022:: with SMTP id ay2mr1609809edb.109.1568672866549; Mon, 16 Sep 2019 15:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568672866; cv=none; d=google.com; s=arc-20160816; b=ZuvWN1jLh4QkntOIOdohqT2OeATbR9ankNIFtYUc4MqimFEXvEXnXd7weD2Lb891oM Sw3Mn2TrcYo8bfrl1jq3//p23X3AnC2GxZjjjSHcTxpWoa0mrO8jCQDMoklJp2RH3sDy qpiaKmmoqQIElgGLD4sikTYIDEhazmffb+79aIP+OwA610DJvxg5vacOh4JPY16rufpj q1kM/oC0/AGdJnCF82GRXGALJmhjekH2hMjygNDoccwBHEEOSoxArJr4HgOsUjxvZ42R b+/XTauc6UbnQ/p5vIdkaQNuaBbEVBwipbq71lKlnzOipQs0604PyebqfkTMICWOcA0c 3qSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ASUn9OH0qpdm5tauYuwAj3Acnc10dNAyecbrZXIKD5k=; b=G2ZufrNON5fi/YqzGkKV6Zd7Mj8XPpkDAaT7XjDghO6QLBnme70/PMWRtwBdAyWJMa Mv/ypJ9rDIPVpUy8htFLGpkk6rYvljlAcvCy3eMaT3BSHYLVQiOWLV5R6Ox7UGzC5RFx pm658wjjMRmsaM0eLc4fbIbZkhK2fFJiIqTN1iqJMbr2FZ05PxxY87JX2pP+3N70F6RN 6fH5eVwSzWmse4QtRTjLxMbolpR5xbQnTXuBp3H8osmbTcQtu4ZScPpsz/NxqqGPHBLX ubtLoS9JI2hGKv3R3wzmL735FyRHhH/bkXIXb2juP3xhHHAMlCFDObvRsM+FkESDMtjE 2F1g== 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 b24si141902eje.85.2019.09.16.15.27.22; Mon, 16 Sep 2019 15:27:46 -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 S2391536AbfIPUos (ORCPT + 99 others); Mon, 16 Sep 2019 16:44:48 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46801 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387513AbfIPUor (ORCPT ); Mon, 16 Sep 2019 16:44:47 -0400 Received: by mail-wr1-f66.google.com with SMTP id o18so777012wrv.13; Mon, 16 Sep 2019 13:44:46 -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:mime-version:content-transfer-encoding; bh=ASUn9OH0qpdm5tauYuwAj3Acnc10dNAyecbrZXIKD5k=; b=IOX9zDkbrJ+ugKjM6mr+410HW+5acMRt7yr8Hz3qpMJN5/ONBRaahTtzK4x5daSAS8 jOugofsotbg4JQghPUJWFMoSS2dWNR38/h5OHYaV1dnXU7k3NyCvRQ2XZdJfW3GRl/jr 2F0Vyb04Mp7Gi9uUISu8XUzpWzvj/Xo+VIm8m4uFpnr4cIcrqDkkLvDoqQchE8swNSk2 E0iEqwd6ci5q41F1tfFmVj6zalRV3Mx/oHXLFUMJa3UHWh8qL6xR/of+M4feOtzmQ+Ms vp2Cw17YvbKmHev+M9RdpC62uQbvroMxTAYvY4RKtYzN74It2DqgC+VzPC53sRjqpsd8 NGrQ== X-Gm-Message-State: APjAAAUc5etJPJ9hUj6vwbCyxeK5t0FNZtwezUAizCMRk1VOpycE3sMq Ir2hwL45diGjWKWURodmiStEEFo4AVw= X-Received: by 2002:a5d:4590:: with SMTP id p16mr190844wrq.82.1568666686310; Mon, 16 Sep 2019 13:44:46 -0700 (PDT) Received: from black.home (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id x6sm231437wmf.38.2019.09.16.13.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:44:45 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-arm-kernel@lists.infradead.org, Alexandre Torgue , Giuseppe Cavallaro Subject: [PATCH v3 10/26] stmmac: pci: Loop using PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:42 +0300 Message-Id: <20190916204158.6889-11-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190916204158.6889-1-efremov@linux.com> References: <20190916204158.6889-1-efremov@linux.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor loops to use idiomatic C style and avoid the fencepost error of using "i < PCI_STD_RESOURCE_END" when "i <= PCI_STD_RESOURCE_END" is required, e.g., commit 2f686f1d9bee ("PCI: Correct PCI_STD_RESOURCE_END usage"). To iterate through all possible BARs, loop conditions changed to the *number* of BARs "i < PCI_STD_NUM_BARS", instead of the index of the last valid BAR "i <= PCI_STD_RESOURCE_END". Cc: Alexandre Torgue Cc: Giuseppe Cavallaro Signed-off-by: Denis Efremov --- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index 86f9c07a38cf..cfe496cdd78b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c @@ -258,7 +258,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev, } /* Get the base address of device */ - for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_len(pdev, i) == 0) continue; ret = pcim_iomap_regions(pdev, BIT(i), pci_name(pdev)); @@ -296,7 +296,7 @@ static void stmmac_pci_remove(struct pci_dev *pdev) stmmac_dvr_remove(&pdev->dev); - for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_len(pdev, i) == 0) continue; pcim_iounmap_regions(pdev, BIT(i)); -- 2.21.0