Skip to content

Commit c254784

Browse files
Wang Jianzhenglinusw
Wang Jianzheng
authored andcommitted
pinctrl: mvebu: Fix devinit_dove_pinctrl_probe function
When an error occurs during the execution of the function __devinit_dove_pinctrl_probe, the clk is not properly disabled. Fix this by calling clk_disable_unprepare before return. Fixes: ba607b6 ("pinctrl: mvebu: make pdma clock on dove mandatory") Signed-off-by: Wang Jianzheng <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 7dc92ec commit c254784

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

drivers/pinctrl/mvebu/pinctrl-dove.c

+29-13
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
767767
struct resource fb_res;
768768
struct mvebu_mpp_ctrl_data *mpp_data;
769769
void __iomem *base;
770-
int i;
770+
int i, ret;
771771

772772
pdev->dev.platform_data = (void *)device_get_match_data(&pdev->dev);
773773

@@ -783,13 +783,17 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
783783
clk_prepare_enable(clk);
784784

785785
base = devm_platform_get_and_ioremap_resource(pdev, 0, &mpp_res);
786-
if (IS_ERR(base))
787-
return PTR_ERR(base);
786+
if (IS_ERR(base)) {
787+
ret = PTR_ERR(base);
788+
goto err_probe;
789+
}
788790

789791
mpp_data = devm_kcalloc(&pdev->dev, dove_pinctrl_info.ncontrols,
790792
sizeof(*mpp_data), GFP_KERNEL);
791-
if (!mpp_data)
792-
return -ENOMEM;
793+
if (!mpp_data) {
794+
ret = -ENOMEM;
795+
goto err_probe;
796+
}
793797

794798
dove_pinctrl_info.control_data = mpp_data;
795799
for (i = 0; i < ARRAY_SIZE(dove_mpp_controls); i++)
@@ -808,8 +812,10 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
808812
}
809813

810814
mpp4_base = devm_ioremap_resource(&pdev->dev, res);
811-
if (IS_ERR(mpp4_base))
812-
return PTR_ERR(mpp4_base);
815+
if (IS_ERR(mpp4_base)) {
816+
ret = PTR_ERR(mpp4_base);
817+
goto err_probe;
818+
}
813819

814820
res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
815821
if (!res) {
@@ -820,8 +826,10 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
820826
}
821827

822828
pmu_base = devm_ioremap_resource(&pdev->dev, res);
823-
if (IS_ERR(pmu_base))
824-
return PTR_ERR(pmu_base);
829+
if (IS_ERR(pmu_base)) {
830+
ret = PTR_ERR(pmu_base);
831+
goto err_probe;
832+
}
825833

826834
gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config");
827835
if (IS_ERR(gconfmap)) {
@@ -831,19 +839,27 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
831839
adjust_resource(&fb_res,
832840
(mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14);
833841
gc_base = devm_ioremap_resource(&pdev->dev, &fb_res);
834-
if (IS_ERR(gc_base))
835-
return PTR_ERR(gc_base);
842+
if (IS_ERR(gc_base)) {
843+
ret = PTR_ERR(gc_base);
844+
goto err_probe;
845+
}
846+
836847
gconfmap = devm_regmap_init_mmio(&pdev->dev,
837848
gc_base, &gc_regmap_config);
838-
if (IS_ERR(gconfmap))
839-
return PTR_ERR(gconfmap);
849+
if (IS_ERR(gconfmap)) {
850+
ret = PTR_ERR(gconfmap);
851+
goto err_probe;
852+
}
840853
}
841854

842855
/* Warn on any missing DT resource */
843856
if (fb_res.start)
844857
dev_warn(&pdev->dev, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n");
845858

846859
return mvebu_pinctrl_probe(pdev);
860+
err_probe:
861+
clk_disable_unprepare(clk);
862+
return ret;
847863
}
848864

849865
static struct platform_driver dove_pinctrl_driver = {

0 commit comments

Comments
 (0)