Skip to content

Commit 91bb8d0

Browse files
Wang Jianzhenglinusw
authored andcommitted
pinctrl: k210: Use devm_clk_get_enabled() helpers
The devm_clk_get_enabled() helpers: - call devm_clk_get() - call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids the calls to clk_disable_unprepare(). Signed-off-by: Wang Jianzheng <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 090e6fe commit 91bb8d0

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

drivers/pinctrl/pinctrl-k210.c

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,6 @@ static int k210_fpioa_probe(struct platform_device *pdev)
925925
struct device *dev = &pdev->dev;
926926
struct device_node *np = dev->of_node;
927927
struct k210_fpioa_data *pdata;
928-
int ret;
929928

930929
dev_info(dev, "K210 FPIOA pin controller\n");
931930

@@ -940,46 +939,28 @@ static int k210_fpioa_probe(struct platform_device *pdev)
940939
if (IS_ERR(pdata->fpioa))
941940
return PTR_ERR(pdata->fpioa);
942941

943-
pdata->clk = devm_clk_get(dev, "ref");
942+
pdata->clk = devm_clk_get_enabled(dev, "ref");
944943
if (IS_ERR(pdata->clk))
945944
return PTR_ERR(pdata->clk);
946945

947-
ret = clk_prepare_enable(pdata->clk);
948-
if (ret)
949-
return ret;
950-
951-
pdata->pclk = devm_clk_get_optional(dev, "pclk");
952-
if (!IS_ERR(pdata->pclk)) {
953-
ret = clk_prepare_enable(pdata->pclk);
954-
if (ret)
955-
goto disable_clk;
956-
}
946+
pdata->pclk = devm_clk_get_optional_enabled(dev, "pclk");
947+
if (IS_ERR(pdata->pclk))
948+
return PTR_ERR(pdata->pclk);
957949

958950
pdata->sysctl_map =
959951
syscon_regmap_lookup_by_phandle_args(np,
960952
"canaan,k210-sysctl-power",
961953
1, &pdata->power_offset);
962-
if (IS_ERR(pdata->sysctl_map)) {
963-
ret = PTR_ERR(pdata->sysctl_map);
964-
goto disable_pclk;
965-
}
954+
if (IS_ERR(pdata->sysctl_map))
955+
return PTR_ERR(pdata->sysctl_map);
966956

967957
k210_fpioa_init_ties(pdata);
968958

969959
pdata->pctl = pinctrl_register(&k210_pinctrl_desc, dev, (void *)pdata);
970-
if (IS_ERR(pdata->pctl)) {
971-
ret = PTR_ERR(pdata->pctl);
972-
goto disable_pclk;
973-
}
960+
if (IS_ERR(pdata->pctl))
961+
return PTR_ERR(pdata->pctl);
974962

975963
return 0;
976-
977-
disable_pclk:
978-
clk_disable_unprepare(pdata->pclk);
979-
disable_clk:
980-
clk_disable_unprepare(pdata->clk);
981-
982-
return ret;
983964
}
984965

985966
static const struct of_device_id k210_fpioa_dt_ids[] = {

0 commit comments

Comments
 (0)