Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ced4d8fa authored by Kuogee Hsieh's avatar Kuogee Hsieh
Browse files

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: default avatarKuogee Hsieh <khsieh@codeaurora.org>
parent 60efae45
Loading
Loading
Loading
Loading
+20 −8
Original line number Diff line number Diff line
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -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;