irqchip/mbigen: Introduce mbigen_of_create_domain()
authorKefeng Wang <wangkefeng.wang@huawei.com>
Tue, 7 Mar 2017 12:40:09 +0000 (20:40 +0800)
committerMarc Zyngier <marc.zyngier@arm.com>
Fri, 7 Apr 2017 09:52:20 +0000 (10:52 +0100)
Introduce mbigen_of_create_domain() to consolidate OF related
code and prepare for ACPI later, no funtional change.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Reviewed-by: Ma Jun <majun258@huawei.com>
Tested-by: Ming Lei <ming.lei@canonical.com>
Tested-by: Wei Xu <xuwei5@hisilicon.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
drivers/irqchip/irq-mbigen.c

index c01ab4100f9aa7dea56ea90d5264e0367feeef17..37564084ce84fca3adc490d6af895c812f6371f6 100644 (file)
@@ -236,27 +236,15 @@ static struct irq_domain_ops mbigen_domain_ops = {
        .free           = irq_domain_free_irqs_common,
 };
 
-static int mbigen_device_probe(struct platform_device *pdev)
+static int mbigen_of_create_domain(struct platform_device *pdev,
+                                  struct mbigen_device *mgn_chip)
 {
-       struct mbigen_device *mgn_chip;
+       struct device *parent;
        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);
-       if (!mgn_chip)
-               return -ENOMEM;
-
-       mgn_chip->pdev = pdev;
-
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       mgn_chip->base = devm_ioremap_resource(&pdev->dev, res);
-       if (IS_ERR(mgn_chip->base))
-               return PTR_ERR(mgn_chip->base);
-
        for_each_child_of_node(pdev->dev.of_node, np) {
                if (!of_property_read_bool(np, "interrupt-controller"))
                        continue;
@@ -280,6 +268,31 @@ static int mbigen_device_probe(struct platform_device *pdev)
                        return -ENOMEM;
        }
 
+       return 0;
+}
+
+static int mbigen_device_probe(struct platform_device *pdev)
+{
+       struct mbigen_device *mgn_chip;
+       struct resource *res;
+       int err;
+
+       mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL);
+       if (!mgn_chip)
+               return -ENOMEM;
+
+       mgn_chip->pdev = pdev;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       mgn_chip->base = devm_ioremap(&pdev->dev, res->start,
+                                     resource_size(res));
+       if (IS_ERR(mgn_chip->base))
+               return PTR_ERR(mgn_chip->base);
+
+       err = mbigen_of_create_domain(pdev, mgn_chip);
+       if (err)
+               return err;
+
        platform_set_drvdata(pdev, mgn_chip);
        return 0;
 }