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

Commit 450b3d73 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: mhl: sii8334: Add mutex lock to avoid race condition"

parents 4a0acb16 121fb2ac
Loading
Loading
Loading
Loading
+16 −12
Original line number Diff line number Diff line
@@ -399,19 +399,22 @@ static int mhl_sii_config(struct mhl_tx_ctrl *mhl_ctrl, bool on)

	client = mhl_ctrl->i2c_handle;

	mutex_lock(&mhl_ctrl->sii_config_lock);
	if (on && !mhl_ctrl->irq_req_done) {
		rc = mhl_vreg_config(mhl_ctrl, 1);
		if (rc) {
			pr_err("%s: vreg init failed [%d]\n",
				__func__, rc);
			return -ENODEV;
			rc = -ENODEV;
			goto vreg_config_error;
		}

		rc = mhl_gpio_config(mhl_ctrl, 1);
		if (rc) {
			pr_err("%s: gpio init failed [%d]\n",
				__func__, rc);
			return -ENODEV;
			rc = -ENODEV;
			goto vreg_config_error;
		}

		rc = request_threaded_irq(mhl_ctrl->i2c_handle->irq, NULL,
@@ -420,9 +423,12 @@ static int mhl_sii_config(struct mhl_tx_ctrl *mhl_ctrl, bool on)
		if (rc) {
			pr_err("%s: request_threaded_irq failed, status: %d\n",
			       __func__, rc);
			return -ENODEV;
			rc = -ENODEV;
			goto vreg_config_error;
		} else {
			mhl_ctrl->irq_req_done = true;
			/* wait for i2c interrupt line to be activated */
			msleep(100);
		}
	} else if (!on && mhl_ctrl->irq_req_done) {
		free_irq(mhl_ctrl->i2c_handle->irq, mhl_ctrl);
@@ -431,6 +437,8 @@ static int mhl_sii_config(struct mhl_tx_ctrl *mhl_ctrl, bool on)
		mhl_ctrl->irq_req_done = false;
	}

vreg_config_error:
	mutex_unlock(&mhl_ctrl->sii_config_lock);
	return rc;
}

@@ -472,17 +480,12 @@ static int mhl_sii_device_discovery(void *data, int id,

	flush_work(&mhl_ctrl->mhl_intr_work);

	if (!mhl_ctrl->irq_req_done) {
	rc = mhl_sii_config(mhl_ctrl, true);
	if (rc) {
		pr_err("%s: Failed to config vreg/gpio\n", __func__);
		return rc;
	}

		/* wait for i2c interrupt line to be activated */
		msleep(100);
	}

	if (!mhl_ctrl->disc_enabled) {
		spin_lock_irqsave(&mhl_ctrl->lock, flags);
		mhl_ctrl->tx_powered_off = false;
@@ -1866,6 +1869,7 @@ static int mhl_i2c_probe(struct i2c_client *client,


	init_completion(&mhl_ctrl->rgnd_done);
	mutex_init(&mhl_ctrl->sii_config_lock);


	mhl_ctrl->mhl_psy.name = "ext-vbus";
+5 −0
Original line number Diff line number Diff line
@@ -163,6 +163,11 @@ struct mhl_tx_ctrl {
	int wr_burst_pending;
	struct completion req_write_done;
	spinlock_t lock;
	/*
	 * Lock between mhl_sii_config and
	 * mhl_sii_device_discovery functions
	*/
	struct mutex sii_config_lock;
	bool tx_powered_off;
	uint8_t dwnstream_hpd;
	bool mhl_det_discon;