From patchwork Tue Mar 10 11:35:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 45574 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B166B214BF for ; Tue, 10 Mar 2015 11:35:17 +0000 (UTC) Received: by widex7 with SMTP id ex7sf1334018wid.2 for ; Tue, 10 Mar 2015 04:35:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=EMmIT0RR2xvtAKm+oqjTG7aZVkk4QyN2EKyPcqVp3TQ=; b=adlb8E0m4tSSnKzpnLqM0LLge9km5n+Yx8PXb6RFkWp4M4J6CnDigAQTTWQDb4LbBM +w9UiphnLjv6EvspToPpDrREgUlWDdjG+dwyzWSzftXLa31i9upmosHhuCf436xBrYK/ 1SKjmYY03O0jOQrLcl7GZXj7LEMEWdy1SRq/FCYJF4fUABQc11M8eFXJqEURuVJRqo4R 6v/w6uw49YRiozhCNitlxgYoqm9wrC1g8x5k6+amwN47oJKtoN5uRpr7OHxu/Kv4kj2t Ne/AMakwQki+q+B/E4CdDODzyVbXMchDOaoYA8OXRCPKTz2LgnRC0s9DGjEFXCa8ZqFz lmuw== X-Gm-Message-State: ALoCoQnHFW3zDYZpMi6VM/NKtKiOH///4pYwqT0sFYhPfeJ1JcvshZNVWSvv7qARAD10vz7CJMDu X-Received: by 10.152.19.67 with SMTP id c3mr3335967lae.7.1425987317045; Tue, 10 Mar 2015 04:35:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.228.169 with SMTP id sj9ls13479lac.35.gmail; Tue, 10 Mar 2015 04:35:16 -0700 (PDT) X-Received: by 10.152.87.199 with SMTP id ba7mr24340188lab.75.1425987316903; Tue, 10 Mar 2015 04:35:16 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id qg6si156441lbb.79.2015.03.10.04.35.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 04:35:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by labmn12 with SMTP id mn12so1013254lab.0 for ; Tue, 10 Mar 2015 04:35:16 -0700 (PDT) X-Received: by 10.152.8.15 with SMTP id n15mr3333117laa.41.1425987316812; Tue, 10 Mar 2015 04:35:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2064207lbj; Tue, 10 Mar 2015 04:35:15 -0700 (PDT) X-Received: by 10.66.164.163 with SMTP id yr3mr32527232pab.154.1425987311483; Tue, 10 Mar 2015 04:35:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10si349293pas.114.2015.03.10.04.35.10; Tue, 10 Mar 2015 04:35:11 -0700 (PDT) Received-SPF: none (google.com: linux-acpi-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752940AbbCJLe7 (ORCPT + 7 others); Tue, 10 Mar 2015 07:34:59 -0400 Received: from mail-la0-f51.google.com ([209.85.215.51]:46742 "EHLO mail-la0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752870AbbCJLex (ORCPT ); Tue, 10 Mar 2015 07:34:53 -0400 Received: by labgm9 with SMTP id gm9so899888lab.13 for ; Tue, 10 Mar 2015 04:34:52 -0700 (PDT) X-Received: by 10.152.170.164 with SMTP id an4mr15209421lac.9.1425987292105; Tue, 10 Mar 2015 04:34:52 -0700 (PDT) Received: from tn-HP-4.semihalf.com (cardhu.semihalf.com. [213.17.239.108]) by mx.google.com with ESMTPSA id n12sm57206lbg.31.2015.03.10.04.34.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Mar 2015 04:34:51 -0700 (PDT) From: Tomasz Nowicki To: bhelgaas@google.com, wangyijing@huawei.com, arnd@arndb.de, hanjun.guo@linaro.org, Liviu.Dudau@arm.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, rjw@rjwysocki.net, al.stone@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linaro-acpi@lists.linaro.org, Tomasz Nowicki Subject: [PATCH v3 6/9] x86, pci: mmconfig_{32, 64}.c code refactoring - remove code duplication. Date: Tue, 10 Mar 2015 12:35:17 +0100 Message-Id: <1425987320-15020-7-git-send-email-tomasz.nowicki@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1425987320-15020-1-git-send-email-tomasz.nowicki@linaro.org> References: <1425987320-15020-1-git-send-email-tomasz.nowicki@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tomasz.nowicki@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , mmconfig_64.c version is going to be default implementation for arch agnostic low-level direct PCI config space accessors for ECAM dirver. However, now it initialize raw_pci_ext_ops pointer which is x86 specific code only. Moreover, mmconfig_32.c is doing the same thing at the same time. Move it to mmconfig_shared.c so it becomes common for both and mmconfig_64.c turns out to be purely arch agnostic. Signed-off-by: Tomasz Nowicki --- arch/x86/pci/mmconfig-shared.c | 10 ++++++++-- arch/x86/pci/mmconfig_32.c | 10 ++-------- arch/x86/pci/mmconfig_64.c | 11 ++--------- include/linux/ecam.h | 5 +++++ 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index 5064302..6dfe614 100644 --- a/arch/x86/pci/mmconfig-shared.c +++ b/arch/x86/pci/mmconfig-shared.c @@ -29,6 +29,11 @@ static bool pci_mmcfg_running_state; static bool pci_mmcfg_arch_init_failed; +const struct pci_raw_ops pci_mmcfg = { + .read = pci_mmcfg_read, + .write = pci_mmcfg_write, +}; + static u32 pci_mmconfig_amd_read(int len, void __iomem *addr) { @@ -532,9 +537,10 @@ static void __init __pci_mmcfg_init(int early) } } - if (pci_mmcfg_arch_init()) + if (pci_mmcfg_arch_init()) { + raw_pci_ext_ops = &pci_mmcfg; pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; - else { + } else { free_all_mmcfg(); pci_mmcfg_arch_init_failed = true; } diff --git a/arch/x86/pci/mmconfig_32.c b/arch/x86/pci/mmconfig_32.c index 5cf6291..7a050cb 100644 --- a/arch/x86/pci/mmconfig_32.c +++ b/arch/x86/pci/mmconfig_32.c @@ -50,7 +50,7 @@ static void pci_exp_set_dev_base(unsigned int base, int bus, int devfn) } } -static int pci_mmcfg_read(unsigned int seg, unsigned int bus, +int pci_mmcfg_read(unsigned int seg, unsigned int bus, unsigned int devfn, int reg, int len, u32 *value) { unsigned long flags; @@ -79,7 +79,7 @@ err: *value = -1; return 0; } -static int pci_mmcfg_write(unsigned int seg, unsigned int bus, +int pci_mmcfg_write(unsigned int seg, unsigned int bus, unsigned int devfn, int reg, int len, u32 value) { unsigned long flags; @@ -106,15 +106,9 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus, return 0; } -const struct pci_raw_ops pci_mmcfg = { - .read = pci_mmcfg_read, - .write = pci_mmcfg_write, -}; - int __init pci_mmcfg_arch_init(void) { printk(KERN_INFO "PCI: Using MMCONFIG for extended config space\n"); - raw_pci_ext_ops = &pci_mmcfg; return 1; } diff --git a/arch/x86/pci/mmconfig_64.c b/arch/x86/pci/mmconfig_64.c index b62ff18..fd857ea 100644 --- a/arch/x86/pci/mmconfig_64.c +++ b/arch/x86/pci/mmconfig_64.c @@ -25,7 +25,7 @@ static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned i return NULL; } -static int pci_mmcfg_read(unsigned int seg, unsigned int bus, +int pci_mmcfg_read(unsigned int seg, unsigned int bus, unsigned int devfn, int reg, int len, u32 *value) { char __iomem *addr; @@ -49,7 +49,7 @@ err: *value = -1; return 0; } -static int pci_mmcfg_write(unsigned int seg, unsigned int bus, +int pci_mmcfg_write(unsigned int seg, unsigned int bus, unsigned int devfn, int reg, int len, u32 value) { char __iomem *addr; @@ -71,11 +71,6 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus, return 0; } -const struct pci_raw_ops pci_mmcfg = { - .read = pci_mmcfg_read, - .write = pci_mmcfg_write, -}; - static void __iomem *mcfg_ioremap(struct pci_mmcfg_region *cfg) { void __iomem *addr; @@ -101,8 +96,6 @@ int __init pci_mmcfg_arch_init(void) return 0; } - raw_pci_ext_ops = &pci_mmcfg; - return 1; } diff --git a/include/linux/ecam.h b/include/linux/ecam.h index 2387df5..fba5d6b 100644 --- a/include/linux/ecam.h +++ b/include/linux/ecam.h @@ -47,5 +47,10 @@ extern struct list_head pci_mmcfg_list; #define PCI_MMCFG_BUS_OFFSET(bus) ((bus) << 20) +int pci_mmcfg_read(unsigned int seg, unsigned int bus, + unsigned int devfn, int reg, int len, u32 *value); +int pci_mmcfg_write(unsigned int seg, unsigned int bus, + unsigned int devfn, int reg, int len, u32 value); + #endif /* __KERNEL__ */ #endif /* __ECAM_H */