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_abhin...@quicinc.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlow...@linaro.org>

---

Changes in v2:
1. Update commit msg
2. Tags
---
 drivers/gpu/drm/msm/dsi/dsi_host.c | 100 +++++++++++++++----------------------
 1 file changed, 41 insertions(+), 59 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c 
b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 
397c9f1f588558b2081d6400d2cbae746c900697..8fc9f5486aebd3c08914409cd3c7824fa0b97515
 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -200,7 +200,8 @@ 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;
        }
 
@@ -208,13 +209,13 @@ static const struct msm_dsi_cfg_handler *dsi_get_config(
 
        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;
        }
 
@@ -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;
 }
 
@@ -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;
@@ -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) {
@@ -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);

-- 
2.43.0

Reply via email to