From patchwork Tue Aug 9 07:05:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 73521 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp341778qga; Tue, 9 Aug 2016 00:12:06 -0700 (PDT) X-Received: by 10.98.36.15 with SMTP id r15mr170713202pfj.1.1470726726508; Tue, 09 Aug 2016 00:12:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ga5si41281284pac.245.2016.08.09.00.12.06; Tue, 09 Aug 2016 00:12:06 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752443AbcHIHLr (ORCPT + 27 others); Tue, 9 Aug 2016 03:11:47 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:13292 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751194AbcHIHLo (ORCPT ); Tue, 9 Aug 2016 03:11:44 -0400 Received: from 172.24.1.60 (EHLO szxeml427-hub.china.huawei.com) ([172.24.1.60]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CGB53223; Tue, 09 Aug 2016 15:07:52 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.235.1; Tue, 9 Aug 2016 15:07:40 +0800 From: Hanjun Guo To: , , CC: "Rafael J. Wysocki" , Marc Zyngier , Thomas Gleixner , Bjorn Helgaas , Greg KH , "Lorenzo Pieralisi" , Tomasz Nowicki , "Ma Jun" , Kefeng Wang , , , , "G Gregory" , Charles Garcia-Tobin , , Hanjun Guo Subject: [RFC PATCH 01/10] irqchip: gicv3-its: platform-msi: refactor its_pmsi_prepare() Date: Tue, 9 Aug 2016 15:05:57 +0800 Message-ID: <1470726366-40809-2-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1470726366-40809-1-git-send-email-guohanjun@huawei.com> References: <1470726366-40809-1-git-send-email-guohanjun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.57A9814A.0017, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 31e87f851596dcfe26208bacbc81b053 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hanjun Guo Adding ACPI support for platform MSI, we need to retrieve the dev id in ACPI way instead of device tree, we already have a well formed function its_pmsi_prepare() to get the dev id but it's OF dependent, so collect OF related code and put them into a single function to make its_pmsi_prepare() more friendly to ACPI later. Signed-off-by: Hanjun Guo --- drivers/irqchip/irq-gic-v3-its-platform-msi.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) -- 1.7.12.4 diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c index 470b4aa..3c94278 100644 --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c @@ -24,15 +24,11 @@ static struct irq_chip its_pmsi_irq_chip = { .name = "ITS-pMSI", }; -static int its_pmsi_prepare(struct irq_domain *domain, struct device *dev, - int nvec, msi_alloc_info_t *info) +static int of_pmsi_get_dev_id(struct irq_domain *domain, struct device *dev, + u32 *dev_id) { - struct msi_domain_info *msi_info; - u32 dev_id; int ret, index = 0; - msi_info = msi_get_domain_info(domain->parent); - /* Suck the DeviceID out of the msi-parent property */ do { struct of_phandle_args args; @@ -43,11 +39,24 @@ static int its_pmsi_prepare(struct irq_domain *domain, struct device *dev, if (args.np == irq_domain_get_of_node(domain)) { if (WARN_ON(args.args_count != 1)) return -EINVAL; - dev_id = args.args[0]; + *dev_id = args.args[0]; break; } } while (!ret); + return ret; +} + +static int its_pmsi_prepare(struct irq_domain *domain, struct device *dev, + int nvec, msi_alloc_info_t *info) +{ + struct msi_domain_info *msi_info; + u32 dev_id; + int ret; + + msi_info = msi_get_domain_info(domain->parent); + + ret = of_pmsi_get_dev_id(domain, dev, &dev_id); if (ret) return ret;