Skip to content

Commit c60738d

Browse files
JunyanYipLorenzo Pieralisi
authored andcommitted
PCI: ftpci100: Release the clock resources
Smatch reported: 1. drivers/pci/controller/pci-ftpci100.c:526 faraday_pci_probe() warn: 'clk' from clk_prepare_enable() not released on lines: 442,451,462,478,512,517. 2. drivers/pci/controller/pci-ftpci100.c:526 faraday_pci_probe() warn: 'p->bus_clk' from clk_prepare_enable() not released on lines: 451,462,478,512,517. The clock resource is obtained by devm_clk_get(), and then clk_prepare_enable() makes the clock resource ready for use. After that, clk_disable_unprepare() should be called to release the clock resource when it is no longer needed. However, while doing some error handling in faraday_pci_probe(), clk_disable_unprepare() is not called to release clk and p->bus_clk before returning. These return lines are exactly 442, 451, 462, 478, 512, 517. Fix this warning by replacing devm_clk_get() with devm_clk_get_enabled(), which is equivalent to devm_clk_get() + clk_prepare_enable(). And with devm_clk_get_enabled(), the clock will automatically be disabled, unprepared and freed when the device is unbound from the bus. Link: https://lore.kernel.org/r/20230508043641.23807-1-yejunyan@hust.edu.cn Fixes: b3c433e ("PCI: faraday: Fix wrong pointer passed to PTR_ERR()") Fixes: 2eeb02b ("PCI: faraday: Add clock handling") Fixes: 783a862 ("PCI: faraday: Use pci_parse_request_of_pci_ranges()") Fixes: d3c68e0 ("PCI: faraday: Add Faraday Technology FTPCI100 PCI Host Bridge driver") Fixes: f1e8bd2 ("PCI: faraday: Convert IRQ masking to raw PCI config accessors") Signed-off-by: Junyan Ye <yejunyan@hust.edu.cn> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
1 parent ac9a786 commit c60738d

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

drivers/pci/controller/pci-ftpci100.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -429,22 +429,12 @@ static int faraday_pci_probe(struct platform_device *pdev)
429429
p->dev = dev;
430430

431431
/* Retrieve and enable optional clocks */
432-
clk = devm_clk_get(dev, "PCLK");
432+
clk = devm_clk_get_enabled(dev, "PCLK");
433433
if (IS_ERR(clk))
434434
return PTR_ERR(clk);
435-
ret = clk_prepare_enable(clk);
436-
if (ret) {
437-
dev_err(dev, "could not prepare PCLK\n");
438-
return ret;
439-
}
440-
p->bus_clk = devm_clk_get(dev, "PCICLK");
435+
p->bus_clk = devm_clk_get_enabled(dev, "PCICLK");
441436
if (IS_ERR(p->bus_clk))
442437
return PTR_ERR(p->bus_clk);
443-
ret = clk_prepare_enable(p->bus_clk);
444-
if (ret) {
445-
dev_err(dev, "could not prepare PCICLK\n");
446-
return ret;
447-
}
448438

449439
p->base = devm_platform_ioremap_resource(pdev, 0);
450440
if (IS_ERR(p->base))

0 commit comments

Comments
 (0)