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

Commit 2d0d60b6 authored by Shantanu Jain's avatar Shantanu Jain
Browse files

misc: isa1200: Add mutex for clk_on



clk_on is a boolean which maintains the enable/disbale
status of clock. To avoid the race condition, mutex call
is added for the clk_on.

CRs-fixed: 507663
Change-Id: If6d933568abc747f3b18497b2c2e743fff4c9e04
Signed-off-by: default avatarShantanu Jain <shjain@codeaurora.org>
parent 86155e46
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ static void isa1200_vib_set(struct isa1200_chip *haptic, int enable)
				}
			}

			mutex_lock(&haptic->client->dev.mutex);
			/* vote for clock */
			if (haptic->pdata->need_pwm_clk && !haptic->clk_on) {
				rc = clk_prepare_enable(haptic->pwm_clk);
@@ -130,6 +131,7 @@ static void isa1200_vib_set(struct isa1200_chip *haptic, int enable)
				}
				haptic->clk_on = true;
			}
			mutex_unlock(&haptic->client->dev.mutex);

			rc = isa1200_write_reg(haptic->client,
						ISA1200_HCTRL5,
@@ -162,11 +164,13 @@ static void isa1200_vib_set(struct isa1200_chip *haptic, int enable)
			if (rc < 0)
				pr_err("%s: stop vibartion fail\n", __func__);

			mutex_lock(&haptic->client->dev.mutex);
			/* de-vote clock */
			if (haptic->pdata->need_pwm_clk && haptic->clk_on) {
				clk_disable_unprepare(haptic->pwm_clk);
				haptic->clk_on = false;
			}
			mutex_unlock(&haptic->client->dev.mutex);
			/* check for board specific clk callback */
			if (haptic->pdata->clk_enable) {
				rc = haptic->pdata->clk_enable(false);
@@ -180,10 +184,12 @@ static void isa1200_vib_set(struct isa1200_chip *haptic, int enable)
	return;

dis_clk:
	mutex_lock(&haptic->client->dev.mutex);
	if (haptic->pdata->need_pwm_clk && haptic->clk_on) {
		clk_disable_unprepare(haptic->pwm_clk);
		haptic->clk_on = false;
	}
	mutex_unlock(&haptic->client->dev.mutex);

dis_clk_cb:
	if (haptic->pdata->clk_enable) {