pinctrl: sunxi: Use devm_clk_get_enabled() helpers
sunxi sunxi_pinctrl_init_with_variant get, enable clk and deinit_device disable and unprepare it. This simplifes the code and avoids the calls to clk_disable_unprepare(). Signed-off-by: Wang Jianzheng <wangjianzheng@vivo.com> Link: https://lore.kernel.org/20240829064737.16169-1-wangjianzheng@vivo.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
5213518d5a
commit
7dc92ece32
@ -1603,30 +1603,26 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = of_clk_get_parent_count(node);
|
ret = of_clk_get_parent_count(node);
|
||||||
clk = devm_clk_get(&pdev->dev, ret == 1 ? NULL : "apb");
|
clk = devm_clk_get_enabled(&pdev->dev, ret == 1 ? NULL : "apb");
|
||||||
if (IS_ERR(clk)) {
|
if (IS_ERR(clk)) {
|
||||||
ret = PTR_ERR(clk);
|
ret = PTR_ERR(clk);
|
||||||
goto gpiochip_error;
|
goto gpiochip_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = clk_prepare_enable(clk);
|
|
||||||
if (ret)
|
|
||||||
goto gpiochip_error;
|
|
||||||
|
|
||||||
pctl->irq = devm_kcalloc(&pdev->dev,
|
pctl->irq = devm_kcalloc(&pdev->dev,
|
||||||
pctl->desc->irq_banks,
|
pctl->desc->irq_banks,
|
||||||
sizeof(*pctl->irq),
|
sizeof(*pctl->irq),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!pctl->irq) {
|
if (!pctl->irq) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto clk_error;
|
goto gpiochip_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < pctl->desc->irq_banks; i++) {
|
for (i = 0; i < pctl->desc->irq_banks; i++) {
|
||||||
pctl->irq[i] = platform_get_irq(pdev, i);
|
pctl->irq[i] = platform_get_irq(pdev, i);
|
||||||
if (pctl->irq[i] < 0) {
|
if (pctl->irq[i] < 0) {
|
||||||
ret = pctl->irq[i];
|
ret = pctl->irq[i];
|
||||||
goto clk_error;
|
goto gpiochip_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1637,7 +1633,7 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev,
|
|||||||
if (!pctl->domain) {
|
if (!pctl->domain) {
|
||||||
dev_err(&pdev->dev, "Couldn't register IRQ domain\n");
|
dev_err(&pdev->dev, "Couldn't register IRQ domain\n");
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto clk_error;
|
goto gpiochip_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < (pctl->desc->irq_banks * IRQ_PER_BANK); i++) {
|
for (i = 0; i < (pctl->desc->irq_banks * IRQ_PER_BANK); i++) {
|
||||||
@ -1669,8 +1665,6 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
clk_error:
|
|
||||||
clk_disable_unprepare(clk);
|
|
||||||
gpiochip_error:
|
gpiochip_error:
|
||||||
gpiochip_remove(pctl->chip);
|
gpiochip_remove(pctl->chip);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user