From patchwork Wed Nov 19 16:04:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 41192 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D78C3241C9 for ; Wed, 19 Nov 2014 16:06:53 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id b6sf635046lbj.8 for ; Wed, 19 Nov 2014 08:06:52 -0800 (PST) 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=dPukexP0UI8298R2faGHJ5/YeSyzcOPlzEVBeFCkb0o=; b=XaOLa9UIK9Ohzn20SO1vkqkgXwWNRVppeCJ31phNCPVpAF40H4t/YJm7KXOAbjRXzQ TBx5HffRa08nVgRVZYUuWF6ThlqJSsYXj2+NYeQCcWzcMLz8FPAPwaAPYMo/y1da8om+ W6W64X3Zy+8Q+8MfJ7g9wdQD+IgL4ju6Vr4e4umR3VVt26+8BnczLNmb/NY9eI7lNF9S mOZV1BNKEpdbvr6OfTb8VWop1fbap6kcRMSo11W1kEq8ovQ0D+kAUyMbLHuhMPsdigoI OGSrEwdReESBnto5sC1bafiCoz9RmHZhkZFrSGdpBr14oKeDueCsbTWulxINk6TkGCoK CqRw== X-Gm-Message-State: ALoCoQlpY9SaoVsHOTzpZYT6d2nZsXEE8uD49sqRITIUzoMTurFwhP3/jYUF5wPy1kpamomGy5qv X-Received: by 10.180.19.42 with SMTP id b10mr2062766wie.0.1416413212836; Wed, 19 Nov 2014 08:06:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.38 with SMTP id ld6ls413752lac.50.gmail; Wed, 19 Nov 2014 08:06:51 -0800 (PST) X-Received: by 10.112.199.100 with SMTP id jj4mr6282347lbc.71.1416413211866; Wed, 19 Nov 2014 08:06:51 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id rj3si2209928lbb.85.2014.11.19.08.06.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Nov 2014 08:06:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id w7so749390lbi.5 for ; Wed, 19 Nov 2014 08:06:51 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr6077582lbo.32.1416413211737; Wed, 19 Nov 2014 08:06:51 -0800 (PST) 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.184.201 with SMTP id ew9csp109705lbc; Wed, 19 Nov 2014 08:06:50 -0800 (PST) X-Received: by 10.70.89.237 with SMTP id br13mr48338271pdb.78.1416413210094; Wed, 19 Nov 2014 08:06:50 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si3434084pat.63.2014.11.19.08.06.48 for ; Wed, 19 Nov 2014 08:06:50 -0800 (PST) Received-SPF: none (google.com: linux-kernel-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 S932377AbaKSQGq (ORCPT + 26 others); Wed, 19 Nov 2014 11:06:46 -0500 Received: from mail-wi0-f178.google.com ([209.85.212.178]:46426 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932264AbaKSQFj (ORCPT ); Wed, 19 Nov 2014 11:05:39 -0500 Received: by mail-wi0-f178.google.com with SMTP id hi2so2404142wib.11 for ; Wed, 19 Nov 2014 08:05:37 -0800 (PST) X-Received: by 10.194.85.161 with SMTP id i1mr14572683wjz.126.1416413137626; Wed, 19 Nov 2014 08:05:37 -0800 (PST) Received: from tn-HP-4.semihalf.com (cardhu.semihalf.com. [213.17.239.108]) by mx.google.com with ESMTPSA id e7sm2842175wjx.31.2014.11.19.08.05.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Nov 2014 08:05:36 -0800 (PST) From: Tomasz Nowicki To: catalin.marinas@arm.com, will.deacon@arm.com, bhelgaas@google.com, lorenzo.pieralisi@arm.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 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 4/6] x86, acpi, pci: mmconfig_{32, 64}.c code refactoring - remove code duplication. Date: Wed, 19 Nov 2014 17:04:49 +0100 Message-Id: <1416413091-13452-5-git-send-email-tomasz.nowicki@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416413091-13452-1-git-send-email-tomasz.nowicki@linaro.org> References: <1416413091-13452-1-git-send-email-tomasz.nowicki@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.217.174 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 via MMCONFIG. However, now it initialize raw_pci_ext_ops pointer which is used in 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 Tested-by: Hanjun Guo --- arch/x86/pci/mmconfig-shared.c | 10 ++++++++-- arch/x86/pci/mmconfig_32.c | 10 ++-------- arch/x86/pci/mmconfig_64.c | 6 ++---- include/linux/mmconfig.h | 4 ++++ 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index b397544..e42004c 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 const char *__init pci_mmcfg_e7520(void) { u32 win; @@ -486,9 +491,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 d774672..c0106a6 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; @@ -89,7 +89,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; @@ -126,15 +126,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 1209596..ff2c50c 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; @@ -59,7 +59,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; @@ -121,8 +121,6 @@ int __init pci_mmcfg_arch_init(void) return 0; } - raw_pci_ext_ops = &pci_mmcfg; - return 1; } diff --git a/include/linux/mmconfig.h b/include/linux/mmconfig.h index 6ccd1ee..ae8ec83 100644 --- a/include/linux/mmconfig.h +++ b/include/linux/mmconfig.h @@ -43,6 +43,10 @@ int pci_mmcfg_arch_init(void); void pci_mmcfg_arch_free(void); int pci_mmcfg_arch_map(struct pci_mmcfg_region *cfg); void pci_mmcfg_arch_unmap(struct pci_mmcfg_region *cfg); +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); extern struct list_head pci_mmcfg_list;