From e43e3b4bca29a2ebe0604a5621b52981fc593e7b Mon Sep 17 00:00:00 2001 From: Kuogee Hsieh Date: Fri, 19 Dec 2014 13:06:02 -0800 Subject: [PATCH] msm: mdss: check lab/ibb regulator before enable Make sure the LAB/IBB regulators are available before start using them. In addition, fix the regulator_disable error return path. CRs-Fixed: 778471 Change-Id: I0a8c3b1f7f13c2699ad58b9c8302c992d076b89d Signed-off-by: Kuogee Hsieh --- drivers/video/fbdev/msm/mdss_dsi.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/msm/mdss_dsi.c b/drivers/video/fbdev/msm/mdss_dsi.c index aabdffb2a416..2a96d5438124 100644 --- a/drivers/video/fbdev/msm/mdss_dsi.c +++ b/drivers/video/fbdev/msm/mdss_dsi.c @@ -53,12 +53,15 @@ static int mdss_dsi_labibb_vreg_init(struct platform_device *pdev) ctrl->lab = regulator_get(&pdev->dev, "lab_reg"); rc = PTR_RET(ctrl->lab); if (rc) { + ctrl->lab = NULL; pr_err("%s: lab_regi get failed.\n", __func__); return rc; } ctrl->ibb = regulator_get(&pdev->dev, "ibb_reg"); rc = PTR_RET(ctrl->ibb); if (rc) { + ctrl->lab = NULL; + ctrl->ibb = NULL; pr_err("%s: ibb_regi get failed.\n", __func__); regulator_put(ctrl->lab); return rc; @@ -75,7 +78,7 @@ static int mdss_dsi_labibb_vreg_ctrl(struct mdss_dsi_ctrl_pdata *ctrl, { int rc; - if (!ctrl->panel_bias_vreg) + if (!ctrl->panel_bias_vreg || !ctrl->lab || !ctrl->ibb) return -EINVAL; pr_debug("%s: ndx=%d enable=%d\n", __func__, ctrl->ndx, enable); @@ -83,23 +86,32 @@ static int mdss_dsi_labibb_vreg_ctrl(struct mdss_dsi_ctrl_pdata *ctrl, if (enable) { rc = regulator_enable(ctrl->lab); if (rc) { - pr_err("%s: falied at lab\n", __func__); + pr_err("%s: enable failed for lab regulator\n", + __func__); return rc; } rc = regulator_enable(ctrl->ibb); if (rc) { - pr_err("%s: falied at ibb\n", __func__); + pr_err("%s: enable failed for ibb regulator\n", + __func__); regulator_disable(ctrl->lab); return rc; } } else { rc = regulator_disable(ctrl->lab); - if (rc) - pr_err("%s: falied at lab\n", __func__); + if (rc) { + pr_err("%s: disable failed for lab regulator\n", + __func__); + return rc; + } + rc = regulator_disable(ctrl->ibb); - if (rc) - pr_err("%s: falied at ibb\n", __func__); + if (rc) { + pr_err("%s: disable failed for ibb regulator\n", + __func__); + return rc; + } } return 0;