From patchwork Fri Aug 18 14:58:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 9909337 X-Patchwork-Delegate: bhelgaas@google.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 BF8B56038C for ; Fri, 18 Aug 2017 15:00:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA1D228670 for ; Fri, 18 Aug 2017 15:00:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF28D28CF7; Fri, 18 Aug 2017 15:00:42 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable 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 71DF228953 for ; Fri, 18 Aug 2017 15:00:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751792AbdHRPA2 (ORCPT ); Fri, 18 Aug 2017 11:00:28 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:25754 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752567AbdHRO7O (ORCPT ); Fri, 18 Aug 2017 10:59:14 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v7IExAwL014088; Fri, 18 Aug 2017 09:59:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1503068350; bh=4W33kzyt359WePY4agZBEB9xXcmvK91mXeapGMSI1LI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Dvxp3WDlk8r6RiLDyMV+Sh+FHvj4oX2XoR2vEh8cM4M1AV4GLkUGlzCHeY/VlMYMn cgMHTNstpBqGDrgySrhBux1hdabtLkDh50kvvpE4SpRrREWA0XElp/hNc98Qu+jFdp EDB199bnRaVFj779kAFS80oWJKiyPRtxvyNyYuYU= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v7IExA51012789; Fri, 18 Aug 2017 09:59:10 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Fri, 18 Aug 2017 09:59:09 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Fri, 18 Aug 2017 09:59:09 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v7IEwKkE023721; Fri, 18 Aug 2017 09:59:07 -0500 From: Kishon Vijay Abraham I To: Bjorn Helgaas CC: Joao Pinto , Arnd Bergmann , , , , , , Subject: [PATCH 16/18] misc: pci_endpoint_test: Avoid using hard coded BAR sizes Date: Fri, 18 Aug 2017 20:28:08 +0530 Message-ID: <20170818145810.17649-17-kishon@ti.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170818145810.17649-1-kishon@ti.com> References: <20170818145810.17649-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP BAR sizes are hard coded in pci_endpoint_test driver corresponding to the sizes used in pci-epf-test function driver. This might break if the sizes in pci-epf-test function driver is modified (and the corresponding change is not done in pci_endpoint_test pci driver). To avoid hard coding BAR sizes, use pci_resource_len API. Signed-off-by: Kishon Vijay Abraham I --- drivers/misc/pci_endpoint_test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 5cbb25cf276c..1f37ad39b169 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -100,8 +100,6 @@ struct pci_endpoint_test_data { bool no_msi; }; -static int bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 }; - static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test, u32 offset) { @@ -149,11 +147,12 @@ static bool pci_endpoint_test_bar(struct pci_endpoint_test *test, int j; u32 val; int size; + struct pci_dev *pdev = test->pdev; if (!test->bar[barno]) return false; - size = bar_size[barno]; + size = pci_resource_len(pdev, barno); if (barno == test->test_reg_bar) size = 0x4;