From patchwork Tue Jun 28 07:53:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9202223 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 8413A6074E for ; Tue, 28 Jun 2016 07:56:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 760362837F for ; Tue, 28 Jun 2016 07:56:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A12D285DF; Tue, 28 Jun 2016 07:56:25 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E183A2837F for ; Tue, 28 Jun 2016 07:56:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHnrJ-00011i-HK; Tue, 28 Jun 2016 07:55:01 +0000 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHnr4-0000km-43 for linux-arm-kernel@lists.infradead.org; Tue, 28 Jun 2016 07:54:46 +0000 Received: by mail-lf0-x232.google.com with SMTP id f6so5560219lfg.0 for ; Tue, 28 Jun 2016 00:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wTIAf9xuuz/A0G7jasjypLHG4h3FMepc23ubCgLX3Uc=; b=EDVa+MMpyda7yMTnUrx7T3S/yESUyctxxbhWujAuS7rOvG3rseG4dTMJSXc2gxMsWh OeKqddfQQJS2DlbQAhTq5qZQytnZqgnn0uwkkEpAInRolSu7U+/D/ttsvDk0maWtuzWj Edk5K+SEVffqYcqCTOt8PHhi3cJJu89oXVIUC8woLupndSlNY8qhZkfvKSXLAjRfrmUa Bq0rhHTTYMz5MjCXVY3ncPLcSSebhjOdUjgyQxX0yjPJYPX59SQK3lSeDu+8RLeL8KSo 7t/EL98A4h3dB+ODqIUC4jArG7vX1Cq/anY9Nn2OKF7NJO7Tsv+blvhtfbdAlro9bdGz ueNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wTIAf9xuuz/A0G7jasjypLHG4h3FMepc23ubCgLX3Uc=; b=FjbVVbdkFB2gJAUMsYoD3jwyixYEZIVpWvRCotKxghWZxzzozcoFfczhOQVBhGxl1P wiEW8hpcx4S9vUWI2TXyfnuWdAMcmGbBE1gzY3W+GRudS6Dw6JvkRLGnruscFjZbSxmx uRoFG5IUt1DPleesNg0dIJcxtPaE2DjKrzS6evnPdSpc/0FVkUHD5K51UEsMFuGeLa3H EUGJx2WqDQFgeUM7RBbermwsx2ZBdQf6Hmc3gZYoTAitN7db8bXOVShJms4+h1iTu2wH wA59hYs/ACh1sihg1BxbPRVGL9wne+uZrY5+JHeVGZ+k8IfQdTfA8mVEEZ+T2/SBWFN7 l8LA== X-Gm-Message-State: ALyK8tIRGuRyPLxJVILmP3kndyelldKtqsi/4crPFxRcRGCSTjZ5vnPOcUydlCTgaH2y8w== X-Received: by 10.25.21.169 with SMTP id 41mr445681lfv.124.1467100464033; Tue, 28 Jun 2016 00:54:24 -0700 (PDT) Received: from tn-HP-4.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id f66sm3856201lji.13.2016.06.28.00.54.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 00:54:23 -0700 (PDT) From: Tomasz Nowicki To: helgaas@kernel.org, arnd@arndb.de, will.deacon@arm.com, catalin.marinas@arm.com, rafael@kernel.org, hanjun.guo@linaro.org, Lorenzo.Pieralisi@arm.com, okaya@codeaurora.org, jchandra@broadcom.com Subject: [RFC PATCH v4 1/5] PCI: Embed pci_ecam_ops in pci_config_window structure Date: Tue, 28 Jun 2016 09:53:58 +0200 Message-Id: <1467100442-28078-2-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467100442-28078-1-git-send-email-tn@semihalf.com> References: <1467100442-28078-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160628_005446_419650_D49FEC13 X-CRM114-Status: GOOD ( 13.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jcm@redhat.com, gabriele.paoloni@huawei.com, linaro-acpi@lists.linaro.org, jhugo@codeaurora.org, linux-pci@vger.kernel.org, dhdang@apm.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, jeremy.linton@arm.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, cov@codeaurora.org, liudongdong3@huawei.com, msalter@redhat.com, wangyijing@huawei.com, Tomasz Nowicki , mw@semihalf.com, andrea.gallo@linaro.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP pci_config_window keeps pointer to pci_ecam_ops and every time we want to deallocate pci_config_window (pci_ecam_free()) we need to make sure to free pci_ecam_ops in case it was dynamically allocated prior to pci_ecam_create() call. To avoid that extra effort, embed pci_ecam_ops in pci_config_window, instead of just a pointer. Signed-off-by: Tomasz Nowicki To: Jayachandran C --- arch/arm64/kernel/pci.c | 2 +- drivers/pci/ecam.c | 6 +++--- include/linux/pci-ecam.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 94cd43c..cb4dee7 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -196,7 +196,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) return NULL; } - acpi_pci_root_ops.pci_ops = &ri->cfg->ops->pci_ops; + acpi_pci_root_ops.pci_ops = &ri->cfg->ops.pci_ops; bus = acpi_pci_root_create(root, &acpi_pci_root_ops, &ri->common, ri->cfg); if (!bus) diff --git a/drivers/pci/ecam.c b/drivers/pci/ecam.c index 43ed08d..24242f0 100644 --- a/drivers/pci/ecam.c +++ b/drivers/pci/ecam.c @@ -52,7 +52,7 @@ struct pci_config_window *pci_ecam_create(struct device *dev, return ERR_PTR(-ENOMEM); cfg->parent = dev; - cfg->ops = ops; + cfg->ops = *ops; cfg->busr.start = busr->start; cfg->busr.end = busr->end; cfg->busr.flags = IORESOURCE_BUS; @@ -138,7 +138,7 @@ void __iomem *pci_ecam_map_bus(struct pci_bus *bus, unsigned int devfn, int where) { struct pci_config_window *cfg = bus->sysdata; - unsigned int devfn_shift = cfg->ops->bus_shift - 8; + unsigned int devfn_shift = cfg->ops.bus_shift - 8; unsigned int busn = bus->number; void __iomem *base; @@ -149,7 +149,7 @@ void __iomem *pci_ecam_map_bus(struct pci_bus *bus, unsigned int devfn, if (per_bus_mapping) base = cfg->winp[busn]; else - base = cfg->win + (busn << cfg->ops->bus_shift); + base = cfg->win + (busn << cfg->ops.bus_shift); return base + (devfn << devfn_shift) + where; } diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h index 7adad20..0ce2920 100644 --- a/include/linux/pci-ecam.h +++ b/include/linux/pci-ecam.h @@ -39,7 +39,7 @@ struct pci_config_window { struct resource res; struct resource busr; void *priv; - struct pci_ecam_ops *ops; + struct pci_ecam_ops ops; union { void __iomem *win; /* 64-bit single mapping */ void __iomem **winp; /* 32-bit per-bus mapping */