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

Commit a9749431 authored by Deva Ramasubramanian's avatar Deva Ramasubramanian Committed by Gerrit - the friendly Code Review server
Browse files

msm: wfd: Lock the state in vsg_start



Protect the state in vsg_start with a mutex as it can be accessed from
other threads.

CRs-Fixed: 634425
Change-Id: I823b34f1b310092ea100d366d92a3293a0c74e6d
Signed-off-by: default avatarDeva Ramasubramanian <dramasub@codeaurora.org>
parent 63875384
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -337,6 +337,7 @@ static int vsg_close(struct v4l2_subdev *sd)
static int vsg_start(struct v4l2_subdev *sd)
static int vsg_start(struct v4l2_subdev *sd)
{
{
	struct vsg_context *context = NULL;
	struct vsg_context *context = NULL;
	int rc = 0;


	if (!sd) {
	if (!sd) {
		WFD_MSG_ERR("ERROR, invalid arguments into %s\n", __func__);
		WFD_MSG_ERR("ERROR, invalid arguments into %s\n", __func__);
@@ -345,18 +346,24 @@ static int vsg_start(struct v4l2_subdev *sd)


	context = (struct vsg_context *)sd->dev_priv;
	context = (struct vsg_context *)sd->dev_priv;


	mutex_lock(&context->mutex);
	if (context->state == VSG_STATE_STARTED) {
	if (context->state == VSG_STATE_STARTED) {
		WFD_MSG_ERR("VSG not stopped, start not allowed\n");
		WFD_MSG_ERR("VSG not stopped, start not allowed\n");
		return -EINPROGRESS;
		rc = -EINPROGRESS;
		goto err_bad_state;
	} else if (context->state == VSG_STATE_ERROR) {
	} else if (context->state == VSG_STATE_ERROR) {
		WFD_MSG_ERR("VSG in error state, not allowed to restart\n");
		WFD_MSG_ERR("VSG in error state, not allowed to restart\n");
		return -ENOTRECOVERABLE;
		rc = -ENOTRECOVERABLE;
		goto err_bad_state;
	}
	}


	context->state = VSG_STATE_STARTED;
	context->state = VSG_STATE_STARTED;
	hrtimer_start(&context->threshold_timer, ns_to_ktime(context->
	hrtimer_start(&context->threshold_timer, ns_to_ktime(context->
			max_frame_interval), HRTIMER_MODE_REL);
			max_frame_interval), HRTIMER_MODE_REL);
	return 0;

err_bad_state:
	mutex_unlock(&context->mutex);
	return rc;
}
}


static int vsg_stop(struct v4l2_subdev *sd)
static int vsg_stop(struct v4l2_subdev *sd)