]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PCI: mediatek-gen3: Move mtk_pcie_setup_irq() out of mtk_pcie_setup()
authorChen-Yu Tsai <wenst@chromium.org>
Tue, 24 Mar 2026 05:19:54 +0000 (13:19 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 25 Mar 2026 18:47:42 +0000 (13:47 -0500)
mtk_pcie_setup_irq() sets up the IRQ domains for PCI INTx and MSI, and
chains them to the controller's interrupt. It doesn't touch the PCIe
controller itself.

Move mtk_pcie_setup_irq() out of mtk_pcie_setup(), do it earlier so there's
nothing to clean up if it fails, and add an error message if it does fail.
Reorder mtk_pcie_irq_teardown() in the remove callback to follow. Also
create an error path in the probe function.

Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
[bhelgaas: commit log]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260324052002.4072430-3-wenst@chromium.org
drivers/pci/controller/pcie-mediatek-gen3.c

index 1939cac995b591fd08d2286bed5813acb1c6c063..04ae195d36c22b4e158286d47f9739d1246fa2db 100644 (file)
@@ -1152,10 +1152,6 @@ static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie)
        if (err)
                goto err_setup;
 
-       err = mtk_pcie_setup_irq(pcie);
-       if (err)
-               goto err_setup;
-
        return 0;
 
 err_setup:
@@ -1181,21 +1177,28 @@ static int mtk_pcie_probe(struct platform_device *pdev)
        pcie->soc = device_get_match_data(dev);
        platform_set_drvdata(pdev, pcie);
 
+       err = mtk_pcie_setup_irq(pcie);
+       if (err)
+               return dev_err_probe(dev, err, "Failed to setup IRQ domains\n");
+
        err = mtk_pcie_setup(pcie);
        if (err)
-               return err;
+               goto err_tear_down_irq;
 
        host->ops = &mtk_pcie_ops;
        host->sysdata = pcie;
 
        err = pci_host_probe(host);
-       if (err) {
-               mtk_pcie_irq_teardown(pcie);
-               mtk_pcie_power_down(pcie);
-               return err;
-       }
+       if (err)
+               goto err_power_down_pcie;
 
        return 0;
+
+err_power_down_pcie:
+       mtk_pcie_power_down(pcie);
+err_tear_down_irq:
+       mtk_pcie_irq_teardown(pcie);
+       return err;
 }
 
 static void mtk_pcie_remove(struct platform_device *pdev)
@@ -1208,8 +1211,8 @@ static void mtk_pcie_remove(struct platform_device *pdev)
        pci_remove_root_bus(host->bus);
        pci_unlock_rescan_remove();
 
-       mtk_pcie_irq_teardown(pcie);
        mtk_pcie_power_down(pcie);
+       mtk_pcie_irq_teardown(pcie);
 }
 
 static void mtk_pcie_irq_save(struct mtk_gen3_pcie *pcie)