Commit d175d6e0 authored by Douglas Anderson's avatar Douglas Anderson Committed by Rob Clark

drm/msm/dsi: Improve dsi_phy_driver_probe() probe error handling

The dsi_phy_driver_probe() function has a "goto fail" for no
reason. Change it to just always return directly when it sees an
error. Make this simpler by leveraging dev_err_probe() which is
designed to make code like this shorter / simpler.

NOTE: as part of this, we now pass through error codes directly from
msm_ioremap_size() rather than translating to -ENOMEM. This changed
mostly because it's much more convenient when using dev_err_probe()
and also it's usually encouraged not to hide error codes like the old
code was doing unless there is a good reason. I can't see any reason
why we'd need to return -ENOMEM instead of -EINVAL from the probe
function.
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/496324/
Link: https://lore.kernel.org/r/20220804073608.v4.6.I969118a35934a0e5007fe4f80e3e28e9c0b7602a@changeidSigned-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
parent d8810a66
...@@ -621,12 +621,9 @@ static int dsi_phy_driver_probe(struct platform_device *pdev) ...@@ -621,12 +621,9 @@ static int dsi_phy_driver_probe(struct platform_device *pdev)
phy->pdev = pdev; phy->pdev = pdev;
phy->id = dsi_phy_get_id(phy); phy->id = dsi_phy_get_id(phy);
if (phy->id < 0) { if (phy->id < 0)
ret = phy->id; return dev_err_probe(dev, phy->id,
DRM_DEV_ERROR(dev, "%s: couldn't identify PHY index, %d\n", "Couldn't identify PHY index\n");
__func__, ret);
goto fail;
}
phy->regulator_ldo_mode = of_property_read_bool(dev->of_node, phy->regulator_ldo_mode = of_property_read_bool(dev->of_node,
"qcom,dsi-phy-regulator-ldo-mode"); "qcom,dsi-phy-regulator-ldo-mode");
...@@ -634,88 +631,71 @@ static int dsi_phy_driver_probe(struct platform_device *pdev) ...@@ -634,88 +631,71 @@ static int dsi_phy_driver_probe(struct platform_device *pdev)
phy->cphy_mode = (phy_type == PHY_TYPE_CPHY); phy->cphy_mode = (phy_type == PHY_TYPE_CPHY);
phy->base = msm_ioremap_size(pdev, "dsi_phy", &phy->base_size); phy->base = msm_ioremap_size(pdev, "dsi_phy", &phy->base_size);
if (IS_ERR(phy->base)) { if (IS_ERR(phy->base))
DRM_DEV_ERROR(dev, "%s: failed to map phy base\n", __func__); return dev_err_probe(dev, PTR_ERR(phy->base),
ret = -ENOMEM; "Failed to map phy base\n");
goto fail;
}
phy->pll_base = msm_ioremap_size(pdev, "dsi_pll", &phy->pll_size); phy->pll_base = msm_ioremap_size(pdev, "dsi_pll", &phy->pll_size);
if (IS_ERR(phy->pll_base)) { if (IS_ERR(phy->pll_base))
DRM_DEV_ERROR(&pdev->dev, "%s: failed to map pll base\n", __func__); return dev_err_probe(dev, PTR_ERR(phy->pll_base),
ret = -ENOMEM; "Failed to map pll base\n");
goto fail;
}
if (phy->cfg->has_phy_lane) { if (phy->cfg->has_phy_lane) {
phy->lane_base = msm_ioremap_size(pdev, "dsi_phy_lane", &phy->lane_size); phy->lane_base = msm_ioremap_size(pdev, "dsi_phy_lane", &phy->lane_size);
if (IS_ERR(phy->lane_base)) { if (IS_ERR(phy->lane_base))
DRM_DEV_ERROR(&pdev->dev, "%s: failed to map phy lane base\n", __func__); return dev_err_probe(dev, PTR_ERR(phy->lane_base),
ret = -ENOMEM; "Failed to map phy lane base\n");
goto fail;
}
} }
if (phy->cfg->has_phy_regulator) { if (phy->cfg->has_phy_regulator) {
phy->reg_base = msm_ioremap_size(pdev, "dsi_phy_regulator", &phy->reg_size); phy->reg_base = msm_ioremap_size(pdev, "dsi_phy_regulator", &phy->reg_size);
if (IS_ERR(phy->reg_base)) { if (IS_ERR(phy->reg_base))
DRM_DEV_ERROR(&pdev->dev, "%s: failed to map phy regulator base\n", __func__); return dev_err_probe(dev, PTR_ERR(phy->reg_base),
ret = -ENOMEM; "Failed to map phy regulator base\n");
goto fail;
}
} }
if (phy->cfg->ops.parse_dt_properties) { if (phy->cfg->ops.parse_dt_properties) {
ret = phy->cfg->ops.parse_dt_properties(phy); ret = phy->cfg->ops.parse_dt_properties(phy);
if (ret) if (ret)
goto fail; return ret;
} }
ret = devm_regulator_bulk_get_const(dev, phy->cfg->num_regulators, ret = devm_regulator_bulk_get_const(dev, phy->cfg->num_regulators,
phy->cfg->regulator_data, phy->cfg->regulator_data,
&phy->supplies); &phy->supplies);
if (ret) if (ret)
goto fail; return ret;
phy->ahb_clk = msm_clk_get(pdev, "iface"); phy->ahb_clk = msm_clk_get(pdev, "iface");
if (IS_ERR(phy->ahb_clk)) { if (IS_ERR(phy->ahb_clk))
DRM_DEV_ERROR(dev, "%s: Unable to get ahb clk\n", __func__); return dev_err_probe(dev, PTR_ERR(phy->ahb_clk),
ret = PTR_ERR(phy->ahb_clk); "Unable to get ahb clk\n");
goto fail;
}
/* PLL init will call into clk_register which requires /* PLL init will call into clk_register which requires
* register access, so we need to enable power and ahb clock. * register access, so we need to enable power and ahb clock.
*/ */
ret = dsi_phy_enable_resource(phy); ret = dsi_phy_enable_resource(phy);
if (ret) if (ret)
goto fail; return ret;
if (phy->cfg->ops.pll_init) { if (phy->cfg->ops.pll_init) {
ret = phy->cfg->ops.pll_init(phy); ret = phy->cfg->ops.pll_init(phy);
if (ret) { if (ret)
DRM_DEV_INFO(dev, return dev_err_probe(dev, ret,
"%s: pll init failed: %d, need separate pll clk driver\n", "PLL init failed; need separate clk driver\n");
__func__, ret);
goto fail;
}
} }
ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
phy->provided_clocks); phy->provided_clocks);
if (ret) { if (ret)
DRM_DEV_ERROR(dev, "%s: failed to register clk provider: %d\n", __func__, ret); return dev_err_probe(dev, ret,
goto fail; "Failed to register clk provider\n");
}
dsi_phy_disable_resource(phy); dsi_phy_disable_resource(phy);
platform_set_drvdata(pdev, phy); platform_set_drvdata(pdev, phy);
return 0; return 0;
fail:
return ret;
} }
static struct platform_driver dsi_phy_platform_driver = { static struct platform_driver dsi_phy_platform_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment