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

Commit 3a4392ac authored by Jigarkumar Zala's avatar Jigarkumar Zala
Browse files

msm: camera: actuator: Add mutex lock during apply and flush request



apply_request and flush_request needs to be protected by mutex in
order to make sure that same i2c index is not being use at the same
time. This change adds mutex lock for that critical section.

Change-Id: I5c3f10f902b3efe1c96cc88ccafb05f2782ad55f
Signed-off-by: default avatarJigarkumar Zala <jzala@codeaurora.org>
parent 77ca1f5a
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ int32_t cam_actuator_apply_request(struct cam_req_mgr_apply_request *apply)
	trace_cam_apply_req("Actuator", apply->request_id);

	CAM_DBG(CAM_ACTUATOR, "Request Id: %lld", apply->request_id);

	mutex_lock(&(a_ctrl->actuator_mutex));
	if ((apply->request_id ==
		a_ctrl->i2c_data.per_frame[request_id].request_id) &&
		(a_ctrl->i2c_data.per_frame[request_id].is_settings_valid)
@@ -312,7 +312,7 @@ int32_t cam_actuator_apply_request(struct cam_req_mgr_apply_request *apply)
			CAM_ERR(CAM_ACTUATOR,
				"Failed in applying the request: %lld\n",
				apply->request_id);
			return rc;
			goto release_mutex;
		}
	}
	del_req_id = (request_id +
@@ -327,12 +327,14 @@ int32_t cam_actuator_apply_request(struct cam_req_mgr_apply_request *apply)
			CAM_ERR(CAM_ACTUATOR,
				"Fail deleting the req: %d err: %d\n",
				del_req_id, rc);
			return rc;
			goto release_mutex;
		}
	} else {
		CAM_DBG(CAM_ACTUATOR, "No Valid Req to clean Up");
	}

release_mutex:
	mutex_unlock(&(a_ctrl->actuator_mutex));
	return rc;
}

@@ -894,7 +896,9 @@ int32_t cam_actuator_flush_request(struct cam_req_mgr_flush_request *flush_req)
			continue;

		if (i2c_set->is_settings_valid == 1) {
			mutex_lock(&(a_ctrl->actuator_mutex));
			rc = delete_request(i2c_set);
			mutex_unlock(&(a_ctrl->actuator_mutex));
			if (rc < 0)
				CAM_ERR(CAM_ACTUATOR,
					"delete request: %lld rc: %d",