Skip to content

Commit eddbac0

Browse files
wensbjorn-helgaas
authored andcommitted
PCI: mediatek-gen3: Move mtk_pcie_setup_irq() out of mtk_pcie_setup()
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
1 parent 9875219 commit eddbac0

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

drivers/pci/controller/pcie-mediatek-gen3.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,10 +1152,6 @@ static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie)
11521152
if (err)
11531153
goto err_setup;
11541154

1155-
err = mtk_pcie_setup_irq(pcie);
1156-
if (err)
1157-
goto err_setup;
1158-
11591155
return 0;
11601156

11611157
err_setup:
@@ -1181,21 +1177,28 @@ static int mtk_pcie_probe(struct platform_device *pdev)
11811177
pcie->soc = device_get_match_data(dev);
11821178
platform_set_drvdata(pdev, pcie);
11831179

1180+
err = mtk_pcie_setup_irq(pcie);
1181+
if (err)
1182+
return dev_err_probe(dev, err, "Failed to setup IRQ domains\n");
1183+
11841184
err = mtk_pcie_setup(pcie);
11851185
if (err)
1186-
return err;
1186+
goto err_tear_down_irq;
11871187

11881188
host->ops = &mtk_pcie_ops;
11891189
host->sysdata = pcie;
11901190

11911191
err = pci_host_probe(host);
1192-
if (err) {
1193-
mtk_pcie_irq_teardown(pcie);
1194-
mtk_pcie_power_down(pcie);
1195-
return err;
1196-
}
1192+
if (err)
1193+
goto err_power_down_pcie;
11971194

11981195
return 0;
1196+
1197+
err_power_down_pcie:
1198+
mtk_pcie_power_down(pcie);
1199+
err_tear_down_irq:
1200+
mtk_pcie_irq_teardown(pcie);
1201+
return err;
11991202
}
12001203

12011204
static void mtk_pcie_remove(struct platform_device *pdev)
@@ -1208,8 +1211,8 @@ static void mtk_pcie_remove(struct platform_device *pdev)
12081211
pci_remove_root_bus(host->bus);
12091212
pci_unlock_rescan_remove();
12101213

1211-
mtk_pcie_irq_teardown(pcie);
12121214
mtk_pcie_power_down(pcie);
1215+
mtk_pcie_irq_teardown(pcie);
12131216
}
12141217

12151218
static void mtk_pcie_irq_save(struct mtk_gen3_pcie *pcie)

0 commit comments

Comments
 (0)