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

Commit 92e360a2 authored by Jigarkumar Zala's avatar Jigarkumar Zala Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: Extend scope of mutex for flush request



There may be chance that flush and release can happen at the same
time. In this situation, flush request can get the control although
release is unlinking it. This change increase scope of mutex for
flush operation to make sure operation happens correctly.

Change-Id: I08520e1133f6fc903eb94463ee384e5ee8d848e2
Signed-off-by: default avatarJigarkumar Zala <jzala@codeaurora.org>
parent a321f0a3
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -901,16 +901,19 @@ int32_t cam_actuator_flush_request(struct cam_req_mgr_flush_request *flush_req)
	if (!flush_req)
		return -EINVAL;

	mutex_lock(&(a_ctrl->actuator_mutex));
	a_ctrl = (struct cam_actuator_ctrl_t *)
		cam_get_device_priv(flush_req->dev_hdl);
	if (!a_ctrl) {
		CAM_ERR(CAM_ACTUATOR, "Device data is NULL");
		return -EINVAL;
		rc = -EINVAL;
		goto end;
	}

	if (a_ctrl->i2c_data.per_frame == NULL) {
		CAM_ERR(CAM_ACTUATOR, "i2c frame data is NULL");
		return -EINVAL;
		rc = -EINVAL;
		goto end;
	}

	if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
@@ -927,9 +930,7 @@ 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",
@@ -948,5 +949,7 @@ int32_t cam_actuator_flush_request(struct cam_req_mgr_flush_request *flush_req)
		CAM_DBG(CAM_ACTUATOR,
			"Flush request id:%lld not found in the pending list",
			flush_req->req_id);
end:
	mutex_unlock(&(a_ctrl->actuator_mutex));
	return rc;
}
+3 −2
Original line number Diff line number Diff line
@@ -387,13 +387,14 @@ int cam_flash_flush_request(struct cam_req_mgr_flush_request *flush)
	int rc = 0;
	struct cam_flash_ctrl *fctrl = NULL;

	mutex_lock(&fctrl->flash_mutex);
	fctrl = (struct cam_flash_ctrl *) cam_get_device_priv(flush->dev_hdl);
	if (!fctrl) {
		CAM_ERR(CAM_FLASH, "Device data is NULL");
		return -EINVAL;
		rc = -EINVAL;
		goto end;
	}

	mutex_lock(&fctrl->flash_mutex);
	if (flush->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
		fctrl->last_flush_req = flush->req_id;
		CAM_DBG(CAM_FLASH, "last reqest to flush is %lld",
+7 −4
Original line number Diff line number Diff line
@@ -1181,16 +1181,19 @@ int32_t cam_sensor_flush_request(struct cam_req_mgr_flush_request *flush_req)
	if (!flush_req)
		return -EINVAL;

	mutex_lock(&(s_ctrl->cam_sensor_mutex));
	s_ctrl = (struct cam_sensor_ctrl_t *)
		cam_get_device_priv(flush_req->dev_hdl);
	if (!s_ctrl) {
		CAM_ERR(CAM_SENSOR, "Device data is NULL");
		return -EINVAL;
		rc = -EINVAL;
		goto end;
	}

	if (s_ctrl->i2c_data.per_frame == NULL) {
		CAM_ERR(CAM_SENSOR, "i2c frame data is NULL");
		return -EINVAL;
		rc = -EINVAL;
		goto end;
	}

	if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
@@ -1207,9 +1210,7 @@ int32_t cam_sensor_flush_request(struct cam_req_mgr_flush_request *flush_req)
			continue;

		if (i2c_set->is_settings_valid == 1) {
			mutex_lock(&(s_ctrl->cam_sensor_mutex));
			rc = delete_request(i2c_set);
			mutex_unlock(&(s_ctrl->cam_sensor_mutex));
			if (rc < 0)
				CAM_ERR(CAM_SENSOR,
					"delete request: %lld rc: %d",
@@ -1228,5 +1229,7 @@ int32_t cam_sensor_flush_request(struct cam_req_mgr_flush_request *flush_req)
		CAM_DBG(CAM_SENSOR,
			"Flush request id:%lld not found in the pending list",
			flush_req->req_id);
end:
	mutex_unlock(&(s_ctrl->cam_sensor_mutex));
	return rc;
}