Skip to content

Commit

Permalink
drm/msm/dsi: Simplify with dev_err_probe()
Browse files Browse the repository at this point in the history
dsi_get_config(), dsi_clk_init() and msm_dsi_host_init() are called only
from platform driver probe function, so using dev_err_probe() is both
appropriate and beneficial:
 - Properly marks device deferred probe status,
 - Avoids dmesg flood on probe deferrals,
 - Already incorporates printing ERR value,
 - Shows device name (in contrast to pr_err()),
 - Makes code smaller and simpler.

Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/637306/
Link: https://lore.kernel.org/r/20250214-drm-msm-cleanups-v2-2-1bec50f37dc1@linaro.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
  • Loading branch information
Krzysztof Kozlowski authored and Dmitry Baryshkov committed Feb 26, 2025
1 parent 709cc06 commit d5bc3c3
Showing 1 changed file with 41 additions and 59 deletions.
100 changes: 41 additions & 59 deletions drivers/gpu/drm/msm/dsi/dsi_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,22 @@ static const struct msm_dsi_cfg_handler *dsi_get_config(

ahb_clk = msm_clk_get(msm_host->pdev, "iface");
if (IS_ERR(ahb_clk)) {
pr_err("%s: cannot get interface clock\n", __func__);
dev_err_probe(dev, PTR_ERR(ahb_clk), "%s: cannot get interface clock\n",
__func__);
goto exit;
}

pm_runtime_get_sync(dev);

ret = clk_prepare_enable(ahb_clk);
if (ret) {
pr_err("%s: unable to enable ahb_clk\n", __func__);
dev_err_probe(dev, ret, "%s: unable to enable ahb_clk\n", __func__);
goto runtime_put;
}

ret = dsi_get_version(msm_host->ctrl_base, &major, &minor);
if (ret) {
pr_err("%s: Invalid version\n", __func__);
dev_err_probe(dev, ret, "%s: Invalid version\n", __func__);
goto disable_clks;
}

Expand Down Expand Up @@ -281,39 +282,31 @@ static int dsi_clk_init(struct msm_dsi_host *msm_host)
msm_host->num_bus_clks = cfg->num_bus_clks;

ret = devm_clk_bulk_get(&pdev->dev, msm_host->num_bus_clks, msm_host->bus_clks);
if (ret < 0) {
dev_err(&pdev->dev, "Unable to get clocks, ret = %d\n", ret);
goto exit;
}
if (ret < 0)
return dev_err_probe(&pdev->dev, ret, "Unable to get clocks\n");

/* get link and source clocks */
msm_host->byte_clk = msm_clk_get(pdev, "byte");
if (IS_ERR(msm_host->byte_clk)) {
ret = PTR_ERR(msm_host->byte_clk);
pr_err("%s: can't find dsi_byte clock. ret=%d\n",
__func__, ret);
goto exit;
}
if (IS_ERR(msm_host->byte_clk))
return dev_err_probe(&pdev->dev, PTR_ERR(msm_host->byte_clk),
"%s: can't find dsi_byte clock\n",
__func__);

msm_host->pixel_clk = msm_clk_get(pdev, "pixel");
if (IS_ERR(msm_host->pixel_clk)) {
ret = PTR_ERR(msm_host->pixel_clk);
pr_err("%s: can't find dsi_pixel clock. ret=%d\n",
__func__, ret);
goto exit;
}
if (IS_ERR(msm_host->pixel_clk))
return dev_err_probe(&pdev->dev, PTR_ERR(msm_host->pixel_clk),
"%s: can't find dsi_pixel clock\n",
__func__);

msm_host->esc_clk = msm_clk_get(pdev, "core");
if (IS_ERR(msm_host->esc_clk)) {
ret = PTR_ERR(msm_host->esc_clk);
pr_err("%s: can't find dsi_esc clock. ret=%d\n",
__func__, ret);
goto exit;
}
if (IS_ERR(msm_host->esc_clk))
return dev_err_probe(&pdev->dev, PTR_ERR(msm_host->esc_clk),
"%s: can't find dsi_esc clock\n",
__func__);

if (cfg_hnd->ops->clk_init_ver)
ret = cfg_hnd->ops->clk_init_ver(msm_host);
exit:

return ret;
}

Expand Down Expand Up @@ -1879,31 +1872,28 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
msm_dsi->host = &msm_host->base;

ret = dsi_host_parse_dt(msm_host);
if (ret) {
pr_err("%s: failed to parse dt\n", __func__);
return ret;
}
if (ret)
return dev_err_probe(&pdev->dev, ret, "%s: failed to parse dt\n",
__func__);

msm_host->ctrl_base = msm_ioremap_size(pdev, "dsi_ctrl", &msm_host->ctrl_size);
if (IS_ERR(msm_host->ctrl_base)) {
pr_err("%s: unable to map Dsi ctrl base\n", __func__);
return PTR_ERR(msm_host->ctrl_base);
}
if (IS_ERR(msm_host->ctrl_base))
return dev_err_probe(&pdev->dev, PTR_ERR(msm_host->ctrl_base),
"%s: unable to map Dsi ctrl base\n", __func__);

pm_runtime_enable(&pdev->dev);

msm_host->cfg_hnd = dsi_get_config(msm_host);
if (!msm_host->cfg_hnd) {
pr_err("%s: get config failed\n", __func__);
return -EINVAL;
}
if (!msm_host->cfg_hnd)
return dev_err_probe(&pdev->dev, -EINVAL,
"%s: get config failed\n", __func__);
cfg = msm_host->cfg_hnd->cfg;

msm_host->id = dsi_host_get_id(msm_host);
if (msm_host->id < 0) {
pr_err("%s: unable to identify DSI host index\n", __func__);
return msm_host->id;
}
if (msm_host->id < 0)
return dev_err_probe(&pdev->dev, msm_host->id,
"%s: unable to identify DSI host index\n",
__func__);

/* fixup base address by io offset */
msm_host->ctrl_base += cfg->io_offset;
Expand All @@ -1915,10 +1905,8 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
return ret;

ret = dsi_clk_init(msm_host);
if (ret) {
pr_err("%s: unable to initialize dsi clks\n", __func__);
return ret;
}
if (ret)
return dev_err_probe(&pdev->dev, ret, "%s: unable to initialize dsi clks\n", __func__);

msm_host->rx_buf = devm_kzalloc(&pdev->dev, SZ_4K, GFP_KERNEL);
if (!msm_host->rx_buf) {
Expand All @@ -1931,26 +1919,20 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
return ret;
/* OPP table is optional */
ret = devm_pm_opp_of_add_table(&pdev->dev);
if (ret && ret != -ENODEV) {
dev_err(&pdev->dev, "invalid OPP table in device tree\n");
return ret;
}
if (ret && ret != -ENODEV)
return dev_err_probe(&pdev->dev, ret, "invalid OPP table in device tree\n");

msm_host->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
if (!msm_host->irq) {
dev_err(&pdev->dev, "failed to get irq\n");
return -EINVAL;
}
if (!msm_host->irq)
return dev_err_probe(&pdev->dev, -EINVAL, "failed to get irq\n");

/* do not autoenable, will be enabled later */
ret = devm_request_irq(&pdev->dev, msm_host->irq, dsi_host_irq,
IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN,
"dsi_isr", msm_host);
if (ret < 0) {
dev_err(&pdev->dev, "failed to request IRQ%u: %d\n",
msm_host->irq, ret);
return ret;
}
if (ret < 0)
return dev_err_probe(&pdev->dev, ret, "failed to request IRQ%u\n",
msm_host->irq);

init_completion(&msm_host->dma_comp);
init_completion(&msm_host->video_comp);
Expand Down

0 comments on commit d5bc3c3

Please sign in to comment.