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: 110409 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp937229obb; Fri, 18 Aug 2017 08:00:31 -0700 (PDT) X-Received: by 10.84.209.202 with SMTP id y68mr9864023plh.474.1503068431839; Fri, 18 Aug 2017 08:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503068431; cv=none; d=google.com; s=arc-20160816; b=f/u/hm96AkE8q1d5JAWMxYeQ1h/Zup6WRsyw5RGAR72+VNgOP5TWRz8z0V+2B6JbVG OC6qay07+gvPaAgGCXKCeBAolDeRtDObbNuAYb5698FwdIYmWH1dE+s3G/SomO37BsJ2 Ij9vYt+GPgPolmMvCAcviNVrDYWw1U/meWlX8Sh0aJ0aAr2JafS26WoBHfsWnBVwjTPT 67HtDID6DRsokE3vdYYRTUCV+LXqtEd+mK7YP3bsRzdKC3trrKNUVqeOISTFNPD2b0UL ku9jXeuAXc1ajtp6AJ4/SD9FxQSImtWCCGhmVJ4/0Z6VUnPO05WNS8iX0FyGEQ+ECThk YGOA== 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:dkim-signature :arc-authentication-results; bh=MAJauyavRcf1rNwVYE38HftAuZVkyXHVETdxym9W/R0=; b=q89jkYogD2ADMu67hpmIqLxSUJv6t8G8Tg10l+5KWsy1iH6Qce31C5QKk9/8kNqniB Qty/wY208DH6eiHlwBXsuZpTzfxBpj+EP0XaB+DEa6rSYEmnfmqcFxavpGgoElpnhkE8 27af2c4PTrIqviPLani282O9K/T/p+43Li0Op5BSwV5MnnAwBEpH6CvbzLFvuC9xU4yO iGK7GbUmygEuw0TIqt6OU0cotq+kupg3qY0dltM12YAUTprZ3vpmoVhK2ZNMqFKmny6A HgwKxFQUwU7QpMTXpBhp0ff5W4hC447mr9WlwY27FgIo9AUUJEQ/GtnYsFP1eCo/vvv9 LtPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Dvxp3WDl; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b186si3605543pgc.941.2017.08.18.08.00.31; Fri, 18 Aug 2017 08:00:31 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Dvxp3WDl; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752729AbdHRPA3 (ORCPT + 26 others); Fri, 18 Aug 2017 11:00:29 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.11.0 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;