Skip to content

Commit afc0cbc

Browse files
Zhang Hengjoergroedel
authored andcommitted
iommu/msm: Use helper function devm_clk_get_prepared()
Since commit 7ef9651 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), devm_clk_get() and clk_prepare() can now be replaced by devm_clk_get_prepared() when driver prepares the clocks for the whole lifetime of the device. Moreover, it is no longer necessary to unprepare the clocks explicitly. Signed-off-by: Zhang Heng <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 78d4f34 commit afc0cbc

File tree

1 file changed

+11
-40
lines changed

1 file changed

+11
-40
lines changed

drivers/iommu/msm_iommu.c

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -725,47 +725,32 @@ static int msm_iommu_probe(struct platform_device *pdev)
725725
iommu->dev = &pdev->dev;
726726
INIT_LIST_HEAD(&iommu->ctx_list);
727727

728-
iommu->pclk = devm_clk_get(iommu->dev, "smmu_pclk");
728+
iommu->pclk = devm_clk_get_prepared(iommu->dev, "smmu_pclk");
729729
if (IS_ERR(iommu->pclk))
730730
return dev_err_probe(iommu->dev, PTR_ERR(iommu->pclk),
731731
"could not get smmu_pclk\n");
732732

733-
ret = clk_prepare(iommu->pclk);
734-
if (ret)
735-
return dev_err_probe(iommu->dev, ret,
736-
"could not prepare smmu_pclk\n");
737-
738-
iommu->clk = devm_clk_get(iommu->dev, "iommu_clk");
739-
if (IS_ERR(iommu->clk)) {
740-
clk_unprepare(iommu->pclk);
733+
iommu->clk = devm_clk_get_prepared(iommu->dev, "iommu_clk");
734+
if (IS_ERR(iommu->clk))
741735
return dev_err_probe(iommu->dev, PTR_ERR(iommu->clk),
742736
"could not get iommu_clk\n");
743-
}
744-
745-
ret = clk_prepare(iommu->clk);
746-
if (ret) {
747-
clk_unprepare(iommu->pclk);
748-
return dev_err_probe(iommu->dev, ret, "could not prepare iommu_clk\n");
749-
}
750737

751738
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
752739
iommu->base = devm_ioremap_resource(iommu->dev, r);
753740
if (IS_ERR(iommu->base)) {
754741
ret = dev_err_probe(iommu->dev, PTR_ERR(iommu->base), "could not get iommu base\n");
755-
goto fail;
742+
return ret;
756743
}
757744
ioaddr = r->start;
758745

759746
iommu->irq = platform_get_irq(pdev, 0);
760-
if (iommu->irq < 0) {
761-
ret = -ENODEV;
762-
goto fail;
763-
}
747+
if (iommu->irq < 0)
748+
return -ENODEV;
764749

765750
ret = of_property_read_u32(iommu->dev->of_node, "qcom,ncb", &val);
766751
if (ret) {
767752
dev_err(iommu->dev, "could not get ncb\n");
768-
goto fail;
753+
return ret;
769754
}
770755
iommu->ncb = val;
771756

@@ -780,8 +765,7 @@ static int msm_iommu_probe(struct platform_device *pdev)
780765

781766
if (!par) {
782767
pr_err("Invalid PAR value detected\n");
783-
ret = -ENODEV;
784-
goto fail;
768+
return -ENODEV;
785769
}
786770

787771
ret = devm_request_threaded_irq(iommu->dev, iommu->irq, NULL,
@@ -791,7 +775,7 @@ static int msm_iommu_probe(struct platform_device *pdev)
791775
iommu);
792776
if (ret) {
793777
pr_err("Request IRQ %d failed with ret=%d\n", iommu->irq, ret);
794-
goto fail;
778+
return ret;
795779
}
796780

797781
list_add(&iommu->dev_node, &qcom_iommu_devices);
@@ -800,44 +784,31 @@ static int msm_iommu_probe(struct platform_device *pdev)
800784
"msm-smmu.%pa", &ioaddr);
801785
if (ret) {
802786
pr_err("Could not add msm-smmu at %pa to sysfs\n", &ioaddr);
803-
goto fail;
787+
return ret;
804788
}
805789

806790
ret = iommu_device_register(&iommu->iommu, &msm_iommu_ops, &pdev->dev);
807791
if (ret) {
808792
pr_err("Could not register msm-smmu at %pa\n", &ioaddr);
809-
goto fail;
793+
return ret;
810794
}
811795

812796
pr_info("device mapped at %p, irq %d with %d ctx banks\n",
813797
iommu->base, iommu->irq, iommu->ncb);
814798

815799
return ret;
816-
fail:
817-
clk_unprepare(iommu->clk);
818-
clk_unprepare(iommu->pclk);
819-
return ret;
820800
}
821801

822802
static const struct of_device_id msm_iommu_dt_match[] = {
823803
{ .compatible = "qcom,apq8064-iommu" },
824804
{}
825805
};
826806

827-
static void msm_iommu_remove(struct platform_device *pdev)
828-
{
829-
struct msm_iommu_dev *iommu = platform_get_drvdata(pdev);
830-
831-
clk_unprepare(iommu->clk);
832-
clk_unprepare(iommu->pclk);
833-
}
834-
835807
static struct platform_driver msm_iommu_driver = {
836808
.driver = {
837809
.name = "msm_iommu",
838810
.of_match_table = msm_iommu_dt_match,
839811
},
840812
.probe = msm_iommu_probe,
841-
.remove = msm_iommu_remove,
842813
};
843814
builtin_platform_driver(msm_iommu_driver);

0 commit comments

Comments
 (0)