From patchwork Sat Apr 28 01:48:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 906006 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Xv6x26Gvz9s08 for ; Sat, 28 Apr 2018 11:56:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759481AbeD1B4k (ORCPT ); Fri, 27 Apr 2018 21:56:40 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:41240 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759307AbeD1B4k (ORCPT ); Fri, 27 Apr 2018 21:56:40 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.177]) by lucky1.263xmail.com (Postfix) with ESMTP id 371C58EDB; Sat, 28 Apr 2018 09:56:38 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id C28583D6; Sat, 28 Apr 2018 09:56:36 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: lorenzo.pieralisi@arm.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <93bbbcc0a536acef0c7c0bf21fb516c9> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 7517VS1V8O; Sat, 28 Apr 2018 09:56:37 +0800 (CST) From: Shawn Lin To: Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Shawn Lin Subject: [PATCH v2 1/9] PCI: Add pci_alloc_intx_irqd() for allocating IRQ domain Date: Sat, 28 Apr 2018 09:48:52 +0800 Message-Id: <1524880132-100904-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> References: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org It seems host drivers which allocate IRQ domain for INTx and the related code block looks highly similar to each other. Add a new helper, pci_alloc_intx_irqd(), to avoid code duplication as much as possible. Signed-off-by: Shawn Lin --- Changes in v2: - fix typo and move the code to C file. drivers/pci/irq.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 10 ++++++++ 2 files changed, 78 insertions(+) diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c index 2a808e1..57fe0f4 100644 --- a/drivers/pci/irq.c +++ b/drivers/pci/irq.c @@ -118,3 +118,71 @@ void pci_free_irq(struct pci_dev *dev, unsigned int nr, void *dev_id) kfree(free_irq(pci_irq_vector(dev, nr), dev_id)); } EXPORT_SYMBOL(pci_free_irq); + +static int pcie_intx_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) +{ + irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); + irq_set_chip_data(irq, domain->host_data); + + return 0; +} + +static struct irq_domain_ops pci_intx_domain_ops = { + .map = pcie_intx_map, +}; + +/** + * pci_alloc_intx_irqd() - Allocate INTx IRQ domain + * @dev: device associated with the PCI controller. + * @host: pointer to host specific data struct + * @general_xlate: flag for whether use pci_irqd_intx_xlate() helper + * @intx_domain_ops: pointer to driver specific struct irq_domain_ops + * @local_intc: pointer to driver specific interrupt controller node + * + * A simple helper for drivers to allocate IRQ domain for INTx. If + * intx_domain_ops is NULL, use pci_intx_domain_ops by default. And if + * local_intc is present, then use it firstly, otherwise, fallback to get + * interrupt controller node from @dev. + * + * Returns valid pointer of struct irq_domain on success, or PTR_ERR(-EINVAL) + * if failure occurred. + */ +struct irq_domain *pci_alloc_intx_irqd(struct device *dev, void *host, + bool general_xlate, const struct irq_domain_ops *intx_domain_ops, + struct device_node *local_intc) +{ + struct device_node *intc = local_intc; + struct irq_domain *domain; + const struct irq_domain_ops *irqd_ops; + bool need_put = false; + + if (!intc) { + intc = of_get_next_child(dev->of_node, NULL); + if (!intc) { + dev_err(dev, "missing child interrupt-controller node\n"); + return ERR_PTR(-EINVAL); + } + need_put = true; + } + + if (intx_domain_ops) { + irqd_ops = intx_domain_ops; + } else { + if (general_xlate) + pci_intx_domain_ops.xlate = &pci_irqd_intx_xlate; + irqd_ops = &pci_intx_domain_ops; + } + + domain = irq_domain_add_linear(intc, PCI_NUM_INTX, + irqd_ops, host); + if (!domain) { + dev_err(dev, "failed to get a INTx IRQ domain\n"); + if (need_put) + of_node_put(intc); + return ERR_PTR(-EINVAL); + } + + return domain; +} +EXPORT_SYMBOL_GPL(pci_alloc_intx_irqd); diff --git a/include/linux/pci.h b/include/linux/pci.h index 73178a2..18cc39f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include @@ -1449,6 +1451,9 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d, return 0; } +extern struct irq_domain *pci_alloc_intx_irqd(struct device *dev, void *host, + bool general_xlate, const struct irq_domain_ops *intx_domain_ops, + struct device_node *local_intc); #ifdef CONFIG_PCIEPORTBUS extern bool pcie_ports_disabled; #else @@ -1683,6 +1688,11 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d, unsigned long *out_hwirq, unsigned int *out_type) { return -EINVAL; } + +static struct irq_domain *pci_alloc_intx_irqd(struct device *dev, void *host, + bool general_xlate, const struct irq_domain_ops *intx_domain_ops, + struct device_node *local_intc) +{ return ERR_PTR(-EINVAL); } #endif /* CONFIG_PCI */ /* Include architecture-dependent settings and functions */ From patchwork Sat Apr 28 01:49:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 906007 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Xv760CRLz9s08 for ; Sat, 28 Apr 2018 11:56:50 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759319AbeD1B4t (ORCPT ); Fri, 27 Apr 2018 21:56:49 -0400 Received: from lucky1.263xmail.com ([211.157.147.135]:43540 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759307AbeD1B4s (ORCPT ); Fri, 27 Apr 2018 21:56:48 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.172]) by lucky1.263xmail.com (Postfix) with ESMTP id E1FAF6D7E; Sat, 28 Apr 2018 09:56:46 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id ABAE03B5; Sat, 28 Apr 2018 09:56:44 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: lorenzo.pieralisi@arm.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <618d2c0906a9e89c8a380bde6340838a> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 28734SBDLK7; Sat, 28 Apr 2018 09:56:46 +0800 (CST) From: Shawn Lin To: Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Shawn Lin , Kishon Vijay Abraham I Subject: [PATCH v2 2/9] PCI: dra7xx: Use pci_alloc_intx_irqd() helper to simplify the code Date: Sat, 28 Apr 2018 09:49:00 +0800 Message-Id: <1524880140-100951-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> References: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Cc: Kishon Vijay Abraham I Signed-off-by: Shawn Lin --- Changes in v2: None drivers/pci/dwc/pci-dra7xx.c | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c index ed8558d..45f6456 100644 --- a/drivers/pci/dwc/pci-dra7xx.c +++ b/drivers/pci/dwc/pci-dra7xx.c @@ -212,43 +212,6 @@ static int dra7xx_pcie_host_init(struct pcie_port *pp) .host_init = dra7xx_pcie_host_init, }; -static int dra7xx_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -static const struct irq_domain_ops intx_domain_ops = { - .map = dra7xx_pcie_intx_map, - .xlate = pci_irqd_intx_xlate, -}; - -static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp) -{ - struct dw_pcie *pci = to_dw_pcie_from_pp(pp); - struct device *dev = pci->dev; - struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); - struct device_node *node = dev->of_node; - struct device_node *pcie_intc_node = of_get_next_child(node, NULL); - - if (!pcie_intc_node) { - dev_err(dev, "No PCIe Intc node found\n"); - return -ENODEV; - } - - dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &intx_domain_ops, pp); - if (!dra7xx->irq_domain) { - dev_err(dev, "Failed to get a INTx IRQ domain\n"); - return -ENODEV; - } - - return 0; -} - static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg) { struct dra7xx_pcie *dra7xx = arg; @@ -454,8 +417,8 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx, return ret; } - ret = dra7xx_pcie_init_irq_domain(pp); - if (ret < 0) + dra7xx->irq_domain = pci_alloc_intx_irqd(dev, dra7xx, true, NULL, NULL); + if (IS_ERR(dra7xx->irq_domain)) return ret; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rc_dbics"); From patchwork Sat Apr 28 01:49:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 906008 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Xv7V31Gzz9s08 for ; Sat, 28 Apr 2018 11:57:10 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759427AbeD1B5J (ORCPT ); Fri, 27 Apr 2018 21:57:09 -0400 Received: from lucky1.263xmail.com ([211.157.147.132]:46507 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759307AbeD1B5J (ORCPT ); Fri, 27 Apr 2018 21:57:09 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.234]) by lucky1.263xmail.com (Postfix) with ESMTP id C67A9691C1; Sat, 28 Apr 2018 09:57:06 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 0242D3B4; Sat, 28 Apr 2018 09:57:04 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: lorenzo.pieralisi@arm.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 7107NN9IVD; Sat, 28 Apr 2018 09:57:06 +0800 (CST) From: Shawn Lin To: Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Shawn Lin , Kishon Vijay Abraham I Subject: [PATCH v2 3/9] PCI: keystone-dw: Use pci_alloc_intx_irqd() helper to get irq domain for INTx Date: Sat, 28 Apr 2018 09:49:20 +0800 Message-Id: <1524880160-100998-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> References: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Cc: Kishon Vijay Abraham I Signed-off-by: Shawn Lin --- Changes in v2: None drivers/pci/dwc/pci-keystone-dw.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/pci/dwc/pci-keystone-dw.c b/drivers/pci/dwc/pci-keystone-dw.c index 0682213..171198a 100644 --- a/drivers/pci/dwc/pci-keystone-dw.c +++ b/drivers/pci/dwc/pci-keystone-dw.c @@ -470,15 +470,11 @@ int __init ks_dw_pcie_host_init(struct keystone_pcie *ks_pcie, ks_pcie->app = *res; /* Create legacy IRQ domain */ - ks_pcie->legacy_irq_domain = - irq_domain_add_linear(ks_pcie->legacy_intc_np, - PCI_NUM_INTX, + ks_pcie->legacy_irq_domain = pci_alloc_intx_irqd(dev, ks_pcie, false, &ks_dw_pcie_legacy_irq_domain_ops, - NULL); - if (!ks_pcie->legacy_irq_domain) { - dev_err(dev, "Failed to add irq domain for legacy irqs\n"); - return -EINVAL; - } + ks_pcie->legacy_intc_np); + if (IS_ERR(ks_pcie->legacy_irq_domain)) + return PTR_ERR(ks_pcie->legacy_irq_domain); return dw_pcie_host_init(pp); } From patchwork Sat Apr 28 01:49:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 906009 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Xv7s0L7Mz9s08 for ; Sat, 28 Apr 2018 11:57:29 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759307AbeD1B52 (ORCPT ); Fri, 27 Apr 2018 21:57:28 -0400 Received: from lucky1.263xmail.com ([211.157.147.131]:42072 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759215AbeD1B51 (ORCPT ); Fri, 27 Apr 2018 21:57:27 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.156]) by lucky1.263xmail.com (Postfix) with ESMTP id 5C52A96B74; Sat, 28 Apr 2018 09:57:25 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id D60BD3D7; Sat, 28 Apr 2018 09:57:23 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: lorenzo.pieralisi@arm.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 278685WEM3L; Sat, 28 Apr 2018 09:57:25 +0800 (CST) From: Shawn Lin To: Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Shawn Lin , Thomas Petazzoni Subject: [PATCH v2 4/9] PCI: aardvark: Use pci_alloc_intx_irqd() helper to get irq domain for INTx Date: Sat, 28 Apr 2018 09:49:29 +0800 Message-Id: <1524880169-101045-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> References: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Cc: Thomas Petazzoni Signed-off-by: Shawn Lin --- Changes in v2: None drivers/pci/host/pci-aardvark.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c index 9abf549..df02b9a 100644 --- a/drivers/pci/host/pci-aardvark.c +++ b/drivers/pci/host/pci-aardvark.c @@ -702,37 +702,23 @@ static void advk_pcie_remove_msi_irq_domain(struct advk_pcie *pcie) static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) { struct device *dev = &pcie->pdev->dev; - struct device_node *node = dev->of_node; - struct device_node *pcie_intc_node; struct irq_chip *irq_chip; - pcie_intc_node = of_get_next_child(node, NULL); - if (!pcie_intc_node) { - dev_err(dev, "No PCIe Intc node found\n"); - return -ENODEV; - } - irq_chip = &pcie->irq_chip; irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq", dev_name(dev)); - if (!irq_chip->name) { - of_node_put(pcie_intc_node); + if (!irq_chip->name) return -ENOMEM; - } irq_chip->irq_mask = advk_pcie_irq_mask; irq_chip->irq_mask_ack = advk_pcie_irq_mask; irq_chip->irq_unmask = advk_pcie_irq_unmask; - pcie->irq_domain = - irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &advk_pcie_irq_domain_ops, pcie); - if (!pcie->irq_domain) { - dev_err(dev, "Failed to get a INTx IRQ domain\n"); - of_node_put(pcie_intc_node); - return -ENOMEM; - } + pcie->irq_domain = pci_alloc_intx_irqd(dev, pcie, false, + &advk_pcie_irq_domain_ops, NULL); + if (IS_ERR(pcie->irq_domain)) + return PTR_ERR(pcie->irq_domain); return 0; } From patchwork Sat Apr 28 01:49:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 906010 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Xv861Jcfz9s08 for ; Sat, 28 Apr 2018 11:57:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759402AbeD1B5l (ORCPT ); Fri, 27 Apr 2018 21:57:41 -0400 Received: from lucky1.263xmail.com ([211.157.147.132]:46730 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759215AbeD1B5l (ORCPT ); Fri, 27 Apr 2018 21:57:41 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.190]) by lucky1.263xmail.com (Postfix) with ESMTP id C322068CDC; Sat, 28 Apr 2018 09:57:38 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 10B903D1; Sat, 28 Apr 2018 09:57:37 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: lorenzo.pieralisi@arm.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 2128LJJQ2G; Sat, 28 Apr 2018 09:57:38 +0800 (CST) From: Shawn Lin To: Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Shawn Lin Subject: [PATCH v2 5/9] PCI: faraday: Use pci_alloc_intx_irqd() helper to get irq domain for INTx Date: Sat, 28 Apr 2018 09:49:48 +0800 Message-Id: <1524880188-101096-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> References: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Signed-off-by: Shawn Lin --- Changes in v2: None drivers/pci/host/pci-ftpci100.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/pci/host/pci-ftpci100.c b/drivers/pci/host/pci-ftpci100.c index 5008fd8..018e4f4 100644 --- a/drivers/pci/host/pci-ftpci100.c +++ b/drivers/pci/host/pci-ftpci100.c @@ -344,24 +344,19 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p) int irq; int i; - if (!intc) { - dev_err(p->dev, "missing child interrupt-controller node\n"); - return -EINVAL; - } + p->irqdomain = pci_alloc_intx_irqd(p->dev, p, false, + &faraday_pci_irqdomain_ops, intc) + if (IS_ERR(p->irqdomain)) + return PTR_ERR(p->irqdomain); /* All PCI IRQs cascade off this one */ irq = of_irq_get(intc, 0); if (irq <= 0) { dev_err(p->dev, "failed to get parent IRQ\n"); + irq_domain_remove(p->irqdomain); return irq ?: -EINVAL; } - p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX, - &faraday_pci_irqdomain_ops, p); - if (!p->irqdomain) { - dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n"); - return -EINVAL; - } irq_set_chained_handler_and_data(irq, faraday_pci_irq_handler, p); From patchwork Sat Apr 28 01:50:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 906011 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Xv8J4fYBz9s08 for ; Sat, 28 Apr 2018 11:57:52 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759421AbeD1B5v (ORCPT ); Fri, 27 Apr 2018 21:57:51 -0400 Received: from lucky1.263xmail.com ([211.157.147.131]:42262 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759215AbeD1B5v (ORCPT ); Fri, 27 Apr 2018 21:57:51 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.157]) by lucky1.263xmail.com (Postfix) with ESMTP id C607C96BA7; Sat, 28 Apr 2018 09:57:48 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 9D3B33FC; Sat, 28 Apr 2018 09:57:47 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: lorenzo.pieralisi@arm.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <373194eb1e94c7054b466c46885f8e3a> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 5880SYWVQK; Sat, 28 Apr 2018 09:57:48 +0800 (CST) From: Shawn Lin To: Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Shawn Lin , Ley Foon Tan Subject: [PATCH v2 6/9] PCI: altera: Use pci_alloc_intx_irqd() helper to get irq domain for INTx Date: Sat, 28 Apr 2018 09:50:03 +0800 Message-Id: <1524880203-101149-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> References: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Cc: Ley Foon Tan Signed-off-by: Shawn Lin --- Changes in v2: None drivers/pci/host/pcie-altera.c | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c index a6af62e..a0fcf0f 100644 --- a/drivers/pci/host/pcie-altera.c +++ b/drivers/pci/host/pcie-altera.c @@ -441,19 +441,6 @@ static void altera_pcie_retrain(struct altera_pcie *pcie) } } -static int altera_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); - irq_set_chip_data(irq, domain->host_data); - return 0; -} - -static const struct irq_domain_ops intx_domain_ops = { - .map = altera_pcie_intx_map, - .xlate = pci_irqd_intx_xlate, -}; - static void altera_pcie_isr(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); @@ -518,22 +505,6 @@ static int altera_pcie_parse_request_of_pci_ranges(struct altera_pcie *pcie) return err; } -static int altera_pcie_init_irq_domain(struct altera_pcie *pcie) -{ - struct device *dev = &pcie->pdev->dev; - struct device_node *node = dev->of_node; - - /* Setup INTx */ - pcie->irq_domain = irq_domain_add_linear(node, PCI_NUM_INTX, - &intx_domain_ops, pcie); - if (!pcie->irq_domain) { - dev_err(dev, "Failed to get a INTx IRQ domain\n"); - return -ENOMEM; - } - - return 0; -} - static int altera_pcie_parse_dt(struct altera_pcie *pcie) { struct device *dev = &pcie->pdev->dev; @@ -591,11 +562,10 @@ static int altera_pcie_probe(struct platform_device *pdev) return ret; } - ret = altera_pcie_init_irq_domain(pcie); - if (ret) { - dev_err(dev, "Failed creating IRQ Domain\n"); - return ret; - } + pcie->irq_domain = pci_alloc_intx_irqd(dev, pcie, true, NULL, + dev->of_node); + if (IS_ERR(pcie->irq_domain)) + return PTR_ERR(pcie->irq_domain); /* clear all interrupts */ cra_writel(pcie, P2A_INT_STS_ALL, P2A_INT_STATUS); From patchwork Sat Apr 28 01:50:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 906012 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Xv8d66YTz9s08 for ; Sat, 28 Apr 2018 11:58:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932841AbeD1B6J (ORCPT ); Fri, 27 Apr 2018 21:58:09 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:42236 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932662AbeD1B6I (ORCPT ); Fri, 27 Apr 2018 21:58:08 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.231]) by lucky1.263xmail.com (Postfix) with ESMTP id 8A5998B51; Sat, 28 Apr 2018 09:58:06 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 13D903CC; Sat, 28 Apr 2018 09:57:59 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: lorenzo.pieralisi@arm.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <1f28098a72002815e82589e258e756a1> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 145168D8UUL; Sat, 28 Apr 2018 09:58:04 +0800 (CST) From: Shawn Lin To: Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Shawn Lin , Ryder Lee Subject: [PATCH v2 7/9] PCI: mediatek: Use pci_alloc_intx_irqd() helper to get irq domain for INTx Date: Sat, 28 Apr 2018 09:50:12 +0800 Message-Id: <1524880212-101211-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> References: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Cc: Ryder Lee Signed-off-by: Shawn Lin --- Changes in v2: None drivers/pci/host/pcie-mediatek.c | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/drivers/pci/host/pcie-mediatek.c b/drivers/pci/host/pcie-mediatek.c index a8b20c5..e977a43 100644 --- a/drivers/pci/host/pcie-mediatek.c +++ b/drivers/pci/host/pcie-mediatek.c @@ -541,38 +541,15 @@ static void mtk_pcie_enable_msi(struct mtk_pcie_port *port) writel(val, port->base + PCIE_INT_MASK); } -static int mtk_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -static const struct irq_domain_ops intx_domain_ops = { - .map = mtk_pcie_intx_map, -}; - static int mtk_pcie_init_irq_domain(struct mtk_pcie_port *port, struct device_node *node) { struct device *dev = port->pcie->dev; - struct device_node *pcie_intc_node; - /* Setup INTx */ - pcie_intc_node = of_get_next_child(node, NULL); - if (!pcie_intc_node) { - dev_err(dev, "no PCIe Intc node found\n"); - return -ENODEV; - } + port->irq_domain = pci_alloc_intx_irqd(dev, port, false, NULL, NULL); + if (IS_ERR(port->irq_domain)) + return PTR_ERR(port->irq_domain); - port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &intx_domain_ops, port); - if (!port->irq_domain) { - dev_err(dev, "failed to get INTx IRQ domain\n"); - return -ENODEV; - } if (IS_ENABLED(CONFIG_PCI_MSI)) { port->msi_domain = irq_domain_add_linear(node, MTK_MSI_IRQS_NUM, From patchwork Sat Apr 28 01:50:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 906013 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Xv8z0KzFz9s0p for ; Sat, 28 Apr 2018 11:58:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932851AbeD1B60 (ORCPT ); Fri, 27 Apr 2018 21:58:26 -0400 Received: from lucky1.263xmail.com ([211.157.147.135]:38581 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932662AbeD1B6Z (ORCPT ); Fri, 27 Apr 2018 21:58:25 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.235]) by lucky1.263xmail.com (Postfix) with ESMTP id 33B956BC9; Sat, 28 Apr 2018 09:58:24 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 53B853B5; Sat, 28 Apr 2018 09:58:18 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: lorenzo.pieralisi@arm.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 4305F6GXE; Sat, 28 Apr 2018 09:58:19 +0800 (CST) From: Shawn Lin To: Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Shawn Lin Subject: [PATCH v2 8/9] PCI: xilinx-nwl: Use pci_alloc_intx_irqd() helper to get irq domain for INTx Date: Sat, 28 Apr 2018 09:50:30 +0800 Message-Id: <1524880230-101309-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> References: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Signed-off-by: Shawn Lin --- Changes in v2: None drivers/pci/host/pcie-xilinx-nwl.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/pci/host/pcie-xilinx-nwl.c b/drivers/pci/host/pcie-xilinx-nwl.c index 4839ae5..1bb77c0 100644 --- a/drivers/pci/host/pcie-xilinx-nwl.c +++ b/drivers/pci/host/pcie-xilinx-nwl.c @@ -544,24 +544,11 @@ static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie) static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie) { struct device *dev = pcie->dev; - struct device_node *node = dev->of_node; - struct device_node *legacy_intc_node; - - legacy_intc_node = of_get_next_child(node, NULL); - if (!legacy_intc_node) { - dev_err(dev, "No legacy intc node found\n"); - return -EINVAL; - } - pcie->legacy_irq_domain = irq_domain_add_linear(legacy_intc_node, - PCI_NUM_INTX, - &legacy_domain_ops, - pcie); - - if (!pcie->legacy_irq_domain) { - dev_err(dev, "failed to create IRQ domain\n"); - return -ENOMEM; - } + pcie->legacy_irq_domain = pci_alloc_intx_irqd(dev, pcie, false, + &legacy_domain_ops, NULL); + if (IS_ERR(pcie->legacy_irq_domain)) + return PTR_ERR(pcie->legacy_irq_domain); raw_spin_lock_init(&pcie->leg_mask_lock); nwl_pcie_init_msi_irq_domain(pcie); From patchwork Sat Apr 28 01:50:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 906014 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Xv995P6gz9s08 for ; Sat, 28 Apr 2018 11:58:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759316AbeD1B6h (ORCPT ); Fri, 27 Apr 2018 21:58:37 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:55936 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759215AbeD1B6g (ORCPT ); Fri, 27 Apr 2018 21:58:36 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.183]) by lucky1.263xmail.com (Postfix) with ESMTP id 5576494CCF; Sat, 28 Apr 2018 09:58:34 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id A70483BE; Sat, 28 Apr 2018 09:58:32 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: lorenzo.pieralisi@arm.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <6768da1842585cfacfaaeacd06969ac9> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 30395XVZ8AD; Sat, 28 Apr 2018 09:58:34 +0800 (CST) From: Shawn Lin To: Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Shawn Lin Subject: [PATCH v2 9/9] PCI: xilinx: Use pci_alloc_intx_irqd() helper to get irq domain for INTx Date: Sat, 28 Apr 2018 09:50:43 +0800 Message-Id: <1524880243-101356-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> References: <1524880102-100856-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Signed-off-by: Shawn Lin --- Changes in v2: None drivers/pci/host/pcie-xilinx.c | 43 +++--------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c index 0ad188e..905668a 100644 --- a/drivers/pci/host/pcie-xilinx.c +++ b/drivers/pci/host/pcie-xilinx.c @@ -344,31 +344,6 @@ static void xilinx_pcie_enable_msi(struct xilinx_pcie_port *port) pcie_write(port, msg_addr, XILINX_PCIE_REG_MSIBASE2); } -/* INTx Functions */ - -/** - * xilinx_pcie_intx_map - Set the handler for the INTx and mark IRQ as valid - * @domain: IRQ domain - * @irq: Virtual IRQ number - * @hwirq: HW interrupt number - * - * Return: Always returns 0. - */ -static int xilinx_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -/* INTx IRQ Domain operations */ -static const struct irq_domain_ops intx_domain_ops = { - .map = xilinx_pcie_intx_map, - .xlate = pci_irqd_intx_xlate, -}; - /* PCIe HW Functions */ /** @@ -495,22 +470,10 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port) { struct device *dev = port->dev; struct device_node *node = dev->of_node; - struct device_node *pcie_intc_node; - /* Setup INTx */ - pcie_intc_node = of_get_next_child(node, NULL); - if (!pcie_intc_node) { - dev_err(dev, "No PCIe Intc node found\n"); - return -ENODEV; - } - - port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &intx_domain_ops, - port); - if (!port->leg_domain) { - dev_err(dev, "Failed to get a INTx IRQ domain\n"); - return -ENODEV; - } + port->leg_domain = pci_alloc_intx_irqd(dev, port, true, NULL, NULL); + if (IS_ERR(port->leg_domain)) + return PTR_ERR(port->leg_domain); /* Setup MSI */ if (IS_ENABLED(CONFIG_PCI_MSI)) {