From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754037AbcCUKdC (ORCPT ); Mon, 21 Mar 2016 06:33:02 -0400 Received: from [198.137.202.10] ([198.137.202.10]:47242 "EHLO terminus.zytor.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752699AbcCUKc4 (ORCPT ); Mon, 21 Mar 2016 06:32:56 -0400 Date: Mon, 21 Mar 2016 03:30:58 -0700 From: tip-bot for MaJun Message-ID: Cc: mingo@kernel.org, majun258@huawei.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com Reply-To: tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org, majun258@huawei.com In-Reply-To: <1458203641-17172-3-git-send-email-majun258@huawei.com> References: <1458203641-17172-3-git-send-email-majun258@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/urgent] irqchip/mbigen: Handle multiple device nodes in a mbigen module Git-Commit-ID: ed2a1002d25ccdb6606c8ccb608524118bd30614 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ed2a1002d25ccdb6606c8ccb608524118bd30614 Gitweb: http://git.kernel.org/tip/ed2a1002d25ccdb6606c8ccb608524118bd30614 Author: MaJun AuthorDate: Thu, 17 Mar 2016 16:34:01 +0800 Committer: Thomas Gleixner CommitDate: Mon, 21 Mar 2016 11:24:11 +0100 irqchip/mbigen: Handle multiple device nodes in a mbigen module Each mbigen device is represented as a independent platform device. If the devices belong to the same mbigen hardware module, then the register space for these devices is the same. That leads to a resource conflict. The solution for this is to represent the mbigen module as a platform device and make the mbigen devices subdevices of that. The register space is associated to the mbigen module and therefor the resource conflict is avoided. [ tglx: Massaged changelog, cleaned up the code and removed the silly printk ] Signed-off-by: Ma Jun Cc: mark.rutland@arm.com Cc: jason@lakedaemon.net Cc: marc.zyngier@arm.com Cc: Catalin.Marinas@arm.com Cc: guohanjun@huawei.com Cc: Will.Deacon@arm.com Cc: huxinwei@huawei.com Cc: lizefan@huawei.com Cc: dingtianhong@huawei.com Cc: zhaojunhua@hisilicon.com Cc: liguozhu@hisilicon.com Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1458203641-17172-3-git-send-email-majun258@huawei.com Signed-off-by: Thomas Gleixner --- drivers/irqchip/irq-mbigen.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c index 4dd3eb8..d67baa2 100644 --- a/drivers/irqchip/irq-mbigen.c +++ b/drivers/irqchip/irq-mbigen.c @@ -239,8 +239,11 @@ static struct irq_domain_ops mbigen_domain_ops = { static int mbigen_device_probe(struct platform_device *pdev) { struct mbigen_device *mgn_chip; - struct resource *res; + struct platform_device *child; struct irq_domain *domain; + struct device_node *np; + struct device *parent; + struct resource *res; u32 num_pins; mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL); @@ -254,23 +257,30 @@ static int mbigen_device_probe(struct platform_device *pdev) if (IS_ERR(mgn_chip->base)) return PTR_ERR(mgn_chip->base); - if (of_property_read_u32(pdev->dev.of_node, "num-pins", &num_pins) < 0) { - dev_err(&pdev->dev, "No num-pins property\n"); - return -EINVAL; - } + for_each_child_of_node(pdev->dev.of_node, np) { + if (!of_property_read_bool(np, "interrupt-controller")) + continue; - domain = platform_msi_create_device_domain(&pdev->dev, num_pins, - mbigen_write_msg, - &mbigen_domain_ops, - mgn_chip); + parent = platform_bus_type.dev_root; + child = of_platform_device_create(np, NULL, parent); + if (IS_ERR(child)) + return PTR_ERR(child); - if (!domain) - return -ENOMEM; + if (of_property_read_u32(child->dev.of_node, "num-pins", + &num_pins) < 0) { + dev_err(&pdev->dev, "No num-pins property\n"); + return -EINVAL; + } + + domain = platform_msi_create_device_domain(&child->dev, num_pins, + mbigen_write_msg, + &mbigen_domain_ops, + mgn_chip); + if (!domain) + return -ENOMEM; + } platform_set_drvdata(pdev, mgn_chip); - - dev_info(&pdev->dev, "Allocated %d MSIs\n", num_pins); - return 0; }