Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6390827ybe; Wed, 18 Sep 2019 02:41:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+sry0yjp3fZ38rgeCPbO+QRyYlpekyMuLzpCD6Qm/OS1W9oJB0dzXWYmI4GCG8MeB65+r X-Received: by 2002:a17:906:6a92:: with SMTP id p18mr8728592ejr.253.1568799708098; Wed, 18 Sep 2019 02:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568799708; cv=none; d=google.com; s=arc-20160816; b=ds1NppJI3h2oe7yyc/1L+MWVKYHCiZYYjfLbq4u3nxkKwVIuUS6TC8fQOfCXPrOvUR 8tzntEtImVOA9YyMRhE8konqrEdJ8Y9PkrkWB16qcXy6ZfBfU+dTnyXLhzgwG5Z0D+8W tuz6LSUynGpsk7OSlpgSGEvMqBdIaoVDW4ffx/7mNQROs7VlkHvNhu8TlJe6ryIXDbVU S6sAwrJwHWlXa9Wvl6/VgBJ6sAI1coJRF3B0ucFgw3/Nevmke1KTyn6sARXNpW51j5ya pX1zha1FjAQdiWn1ScR7FedD3X8yrYBaIc3UDtCm1S5KvWzSupdqx7qPi00aF9wZo19G xxNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=O3lapEPc6FWVFtXrQ2YxmOvT3RN0LOq3BkSIM2z5nxE=; b=vz74RhMXy5JE90vyx6lzQzA8O/1aZJNmV/D3i6ttQJMqhtmj5aqzyiKCZsD0ExFOV6 7mtWWeXBAvIdS0oGhJZcq2hlCwD3sdsoUiGGq8/OgLfBl/fL3O+xcmfapVHmY47l5r3E ujTF4Ch9tKjJrh+RcDkmhtewdqHqQaZoCSnx/gi6Q04XmpLGFpxL6bNjOPKkcxrIpwf5 ZtcWD84eeRrKPYNMOCOE7JKl+5HtOI2G6ixgwCd9Gg4eer4+N4cmjcMo/6+x3abfAWot WWV80gGLVvZk79IBzCZumaWJCrZfWaLW1qqEx73H3qqBa13tdyKA/5LikmdK0wETcTrm GWFg== 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 qx16si2423501ejb.279.2019.09.18.02.41.24; Wed, 18 Sep 2019 02:41:48 -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 S1730191AbfIRJFv (ORCPT + 99 others); Wed, 18 Sep 2019 05:05:51 -0400 Received: from foss.arm.com ([217.140.110.172]:37806 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbfIRJFv (ORCPT ); Wed, 18 Sep 2019 05:05:51 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 75E90337; Wed, 18 Sep 2019 02:05:50 -0700 (PDT) Received: from localhost (unknown [10.37.6.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E06CF3F59C; Wed, 18 Sep 2019 02:05:49 -0700 (PDT) Date: Wed, 18 Sep 2019 10:05:48 +0100 From: Andrew Murray To: Denis Efremov Cc: Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org, Jeff Kirsher , "David S. Miller" Subject: Re: [PATCH v3 13/26] e1000: Use PCI_STD_NUM_BARS Message-ID: <20190918090547.GZ9720@e119886-lin.cambridge.arm.com> References: <20190916204158.6889-1-efremov@linux.com> <20190916204158.6889-14-efremov@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190916204158.6889-14-efremov@linux.com> User-Agent: Mutt/1.10.1+81 (426a6c1) (2018-08-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 16, 2019 at 11:41:45PM +0300, Denis Efremov wrote: > To iterate through all possible BARs, loop conditions refactored to the > *number* of BARs "i < PCI_STD_NUM_BARS", instead of the index of the last > valid BAR "i <= BAR_5". This is more idiomatic C style and allows to avoid > the fencepost error. > > Cc: Jeff Kirsher > Cc: "David S. Miller" > Signed-off-by: Denis Efremov > --- > drivers/net/ethernet/intel/e1000/e1000.h | 1 - > drivers/net/ethernet/intel/e1000/e1000_main.c | 2 +- > 2 files changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/intel/e1000/e1000.h b/drivers/net/ethernet/intel/e1000/e1000.h > index c40729b2c184..7fad2f24dcad 100644 > --- a/drivers/net/ethernet/intel/e1000/e1000.h > +++ b/drivers/net/ethernet/intel/e1000/e1000.h > @@ -45,7 +45,6 @@ > > #define BAR_0 0 > #define BAR_1 1 > -#define BAR_5 5 No issue with this patch. However I noticed that at least 5 of the network drivers have these same definitions, which are identical to the pci_barno enum of include/linux/pci-epf.h. There are mostly used with pci_ioremap_bar and pci_resource_** macros. I wonder if this is an indicator that these defintions should live in the core. Thanks, Andrew Murray > > #define INTEL_E1000_ETHERNET_DEVICE(device_id) {\ > PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)} > diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c > index f703fa58458e..db4fd82036af 100644 > --- a/drivers/net/ethernet/intel/e1000/e1000_main.c > +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c > @@ -977,7 +977,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > goto err_ioremap; > > if (adapter->need_ioport) { > - for (i = BAR_1; i <= BAR_5; i++) { > + for (i = BAR_1; i < PCI_STD_NUM_BARS; i++) { > if (pci_resource_len(pdev, i) == 0) > continue; > if (pci_resource_flags(pdev, i) & IORESOURCE_IO) { > -- > 2.21.0 >