Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: mobiveil: Collect the interrupt related operations into a function

Collect the interrupt initialization related operations into
a new function to make code more readable.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Andrew Murray <amurray@thegoodpenguin.co.uk>

authored by

Hou Zhiqiang and committed by
Lorenzo Pieralisi
39e3a03e 2ba24842

+42 -23
+42 -23
drivers/pci/controller/pcie-mobiveil.c
··· 454 454 return PTR_ERR(pcie->csr_axi_slave_base); 455 455 pcie->pcie_reg_base = res->start; 456 456 457 - /* map MSI config resource */ 458 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "apb_csr"); 459 - pcie->apb_csr_base = devm_pci_remap_cfg_resource(dev, res); 460 - if (IS_ERR(pcie->apb_csr_base)) 461 - return PTR_ERR(pcie->apb_csr_base); 462 - 463 457 /* read the number of windows requested */ 464 458 if (of_property_read_u32(node, "apio-wins", &pcie->apio_wins)) 465 459 pcie->apio_wins = MAX_PIO_WINDOWS; 466 460 467 461 if (of_property_read_u32(node, "ppio-wins", &pcie->ppio_wins)) 468 462 pcie->ppio_wins = MAX_PIO_WINDOWS; 469 - 470 - rp->irq = platform_get_irq(pdev, 0); 471 - if (rp->irq <= 0) { 472 - dev_err(dev, "failed to map IRQ: %d\n", rp->irq); 473 - return -ENODEV; 474 - } 475 463 476 464 return 0; 477 465 } ··· 606 618 pab_ctrl |= (1 << AMBA_PIO_ENABLE_SHIFT) | (1 << PEX_PIO_ENABLE_SHIFT); 607 619 mobiveil_csr_writel(pcie, pab_ctrl, PAB_CTRL); 608 620 609 - mobiveil_csr_writel(pcie, (PAB_INTP_INTX_MASK | PAB_INTP_MSI_MASK), 610 - PAB_INTP_AMBA_MISC_ENB); 611 - 612 621 /* 613 622 * program PIO Enable Bit to 1 and Config Window Enable Bit to 1 in 614 623 * PAB_AXI_PIO_CTRL Register ··· 654 669 value &= 0xff; 655 670 value |= (PCI_CLASS_BRIDGE_PCI << 16); 656 671 mobiveil_csr_writel(pcie, value, PAB_INTP_AXI_PIO_CLASS); 657 - 658 - /* setup MSI hardware registers */ 659 - mobiveil_pcie_enable_msi(pcie); 660 672 661 673 return 0; 662 674 } ··· 855 873 return 0; 856 874 } 857 875 876 + static int mobiveil_pcie_interrupt_init(struct mobiveil_pcie *pcie) 877 + { 878 + struct platform_device *pdev = pcie->pdev; 879 + struct device *dev = &pdev->dev; 880 + struct mobiveil_root_port *rp = &pcie->rp; 881 + struct resource *res; 882 + int ret; 883 + 884 + /* map MSI config resource */ 885 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "apb_csr"); 886 + pcie->apb_csr_base = devm_pci_remap_cfg_resource(dev, res); 887 + if (IS_ERR(pcie->apb_csr_base)) 888 + return PTR_ERR(pcie->apb_csr_base); 889 + 890 + /* setup MSI hardware registers */ 891 + mobiveil_pcie_enable_msi(pcie); 892 + 893 + rp->irq = platform_get_irq(pdev, 0); 894 + if (rp->irq <= 0) { 895 + dev_err(dev, "failed to map IRQ: %d\n", rp->irq); 896 + return -ENODEV; 897 + } 898 + 899 + /* initialize the IRQ domains */ 900 + ret = mobiveil_pcie_init_irq_domain(pcie); 901 + if (ret) { 902 + dev_err(dev, "Failed creating IRQ Domain\n"); 903 + return ret; 904 + } 905 + 906 + irq_set_chained_handler_and_data(rp->irq, mobiveil_pcie_isr, pcie); 907 + 908 + /* Enable interrupts */ 909 + mobiveil_csr_writel(pcie, (PAB_INTP_INTX_MASK | PAB_INTP_MSI_MASK), 910 + PAB_INTP_AMBA_MISC_ENB); 911 + 912 + 913 + return 0; 914 + } 915 + 858 916 static int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie) 859 917 { 860 918 struct mobiveil_root_port *rp = &pcie->rp; ··· 928 906 return ret; 929 907 } 930 908 931 - /* initialize the IRQ domains */ 932 - ret = mobiveil_pcie_init_irq_domain(pcie); 909 + ret = mobiveil_pcie_interrupt_init(pcie); 933 910 if (ret) { 934 - dev_err(dev, "Failed creating IRQ Domain\n"); 911 + dev_err(dev, "Interrupt init failed\n"); 935 912 return ret; 936 913 } 937 - 938 - irq_set_chained_handler_and_data(rp->irq, mobiveil_pcie_isr, pcie); 939 914 940 915 /* Initialize bridge */ 941 916 bridge->dev.parent = dev;