diff options
author | Fei Shao <fshao@chromium.org> | 2023-12-06 15:17:27 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-12-15 17:27:04 +0100 |
commit | ffdfbafdc4f46a92e6bebaa61048b9f56301e2fa (patch) | |
tree | 1479f8dde791c8c67f36b2b0454c10f0d7e78ab1 /drivers/spmi/spmi-mtk-pmif.c | |
parent | b6e53731e07db7e8d35b789fd83565fe75540180 (diff) | |
download | lwn-ffdfbafdc4f46a92e6bebaa61048b9f56301e2fa.tar.gz lwn-ffdfbafdc4f46a92e6bebaa61048b9f56301e2fa.zip |
spmi: Use devm_spmi_controller_alloc()
Convert to the device-managed version of spmi_controller_alloc() and
simplify the excess error handling code.
Signed-off-by: Fei Shao <fshao@chromium.org>
Link: https://lore.kernel.org/r/20230824104101.4083400-3-fshao@chromium.org
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20231206231733.4031901-5-sboyd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/spmi/spmi-mtk-pmif.c')
-rw-r--r-- | drivers/spmi/spmi-mtk-pmif.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/spmi/spmi-mtk-pmif.c b/drivers/spmi/spmi-mtk-pmif.c index 1261f381cae6..6ebc6901490a 100644 --- a/drivers/spmi/spmi-mtk-pmif.c +++ b/drivers/spmi/spmi-mtk-pmif.c @@ -447,29 +447,24 @@ static int mtk_spmi_probe(struct platform_device *pdev) int err, i; u32 chan_offset; - ctrl = spmi_controller_alloc(&pdev->dev, sizeof(*arb)); - if (!ctrl) - return -ENOMEM; + ctrl = devm_spmi_controller_alloc(&pdev->dev, sizeof(*arb)); + if (IS_ERR(ctrl)) + return PTR_ERR(ctrl); arb = spmi_controller_get_drvdata(ctrl); arb->data = device_get_match_data(&pdev->dev); if (!arb->data) { - err = -EINVAL; dev_err(&pdev->dev, "Cannot get drv_data\n"); - goto err_put_ctrl; + return -EINVAL; } arb->base = devm_platform_ioremap_resource_byname(pdev, "pmif"); - if (IS_ERR(arb->base)) { - err = PTR_ERR(arb->base); - goto err_put_ctrl; - } + if (IS_ERR(arb->base)) + return PTR_ERR(arb->base); arb->spmimst_base = devm_platform_ioremap_resource_byname(pdev, "spmimst"); - if (IS_ERR(arb->spmimst_base)) { - err = PTR_ERR(arb->spmimst_base); - goto err_put_ctrl; - } + if (IS_ERR(arb->spmimst_base)) + return PTR_ERR(arb->spmimst_base); arb->nclks = ARRAY_SIZE(pmif_clock_names); for (i = 0; i < arb->nclks; i++) @@ -478,7 +473,7 @@ static int mtk_spmi_probe(struct platform_device *pdev) err = clk_bulk_get(&pdev->dev, arb->nclks, arb->clks); if (err) { dev_err(&pdev->dev, "Failed to get clocks: %d\n", err); - goto err_put_ctrl; + return err; } err = clk_bulk_prepare_enable(arb->nclks, arb->clks); @@ -512,8 +507,6 @@ err_domain_remove: clk_bulk_disable_unprepare(arb->nclks, arb->clks); err_put_clks: clk_bulk_put(arb->nclks, arb->clks); -err_put_ctrl: - spmi_controller_put(ctrl); return err; } @@ -525,7 +518,6 @@ static void mtk_spmi_remove(struct platform_device *pdev) clk_bulk_disable_unprepare(arb->nclks, arb->clks); clk_bulk_put(arb->nclks, arb->clks); spmi_controller_remove(ctrl); - spmi_controller_put(ctrl); } static const struct of_device_id mtk_spmi_match_table[] = { |