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 <wangjianzheng@vivo.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Link: https://lore.kernel.org/20240829064938.20114-1-wangjianzheng@vivo.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
090e6fea5f
commit
91bb8d0bf2
@ -925,7 +925,6 @@ static int k210_fpioa_probe(struct platform_device *pdev)
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *np = dev->of_node;
|
||||
struct k210_fpioa_data *pdata;
|
||||
int ret;
|
||||
|
||||
dev_info(dev, "K210 FPIOA pin controller\n");
|
||||
|
||||
@ -940,46 +939,28 @@ static int k210_fpioa_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(pdata->fpioa))
|
||||
return PTR_ERR(pdata->fpioa);
|
||||
|
||||
pdata->clk = devm_clk_get(dev, "ref");
|
||||
pdata->clk = devm_clk_get_enabled(dev, "ref");
|
||||
if (IS_ERR(pdata->clk))
|
||||
return PTR_ERR(pdata->clk);
|
||||
|
||||
ret = clk_prepare_enable(pdata->clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
pdata->pclk = devm_clk_get_optional(dev, "pclk");
|
||||
if (!IS_ERR(pdata->pclk)) {
|
||||
ret = clk_prepare_enable(pdata->pclk);
|
||||
if (ret)
|
||||
goto disable_clk;
|
||||
}
|
||||
pdata->pclk = devm_clk_get_optional_enabled(dev, "pclk");
|
||||
if (IS_ERR(pdata->pclk))
|
||||
return PTR_ERR(pdata->pclk);
|
||||
|
||||
pdata->sysctl_map =
|
||||
syscon_regmap_lookup_by_phandle_args(np,
|
||||
"canaan,k210-sysctl-power",
|
||||
1, &pdata->power_offset);
|
||||
if (IS_ERR(pdata->sysctl_map)) {
|
||||
ret = PTR_ERR(pdata->sysctl_map);
|
||||
goto disable_pclk;
|
||||
}
|
||||
if (IS_ERR(pdata->sysctl_map))
|
||||
return PTR_ERR(pdata->sysctl_map);
|
||||
|
||||
k210_fpioa_init_ties(pdata);
|
||||
|
||||
pdata->pctl = pinctrl_register(&k210_pinctrl_desc, dev, (void *)pdata);
|
||||
if (IS_ERR(pdata->pctl)) {
|
||||
ret = PTR_ERR(pdata->pctl);
|
||||
goto disable_pclk;
|
||||
}
|
||||
if (IS_ERR(pdata->pctl))
|
||||
return PTR_ERR(pdata->pctl);
|
||||
|
||||
return 0;
|
||||
|
||||
disable_pclk:
|
||||
clk_disable_unprepare(pdata->pclk);
|
||||
disable_clk:
|
||||
clk_disable_unprepare(pdata->clk);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct of_device_id k210_fpioa_dt_ids[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user