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

Commit ad347285 authored by Karthik Anantha Ram's avatar Karthik Anantha Ram
Browse files

msm: camera: icp: Change function return value only to report err



Currently hfi_read_message returns a negative value in case of
error otherwise the words read from the queue as return value.
This change passes an input param that is populated with number
of words read from the queue in a given call. The return value
will only report a success or failure.

Change-Id: I6e60c20131735432b2022a06fdef3b1baa29e7cb
Signed-off-by: default avatarKarthik Anantha Ram <kartanan@codeaurora.org>
parent 6e4bc937
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -60,10 +60,12 @@ int hfi_write_cmd(void *cmd_ptr);
 * hfi_read_message() - function for hfi read
 * @pmsg: buffer to place read message for hfi queue
 * @q_id: queue id
 * @words_read: total number of words read from the queue
 *              returned as output to the caller
 *
 * Returns size read in words/failure(negative value)
 * Returns success(zero)/failure(non zero)
 */
int64_t hfi_read_message(uint32_t *pmsg, uint8_t q_id);
int hfi_read_message(uint32_t *pmsg, uint8_t q_id, uint32_t *words_read);

/**
 * hfi_init() - function initialize hfi after firmware download
+4 −3
Original line number Diff line number Diff line
@@ -117,13 +117,14 @@ int hfi_write_cmd(void *cmd_ptr)
	return rc;
}

int64_t hfi_read_message(uint32_t *pmsg, uint8_t q_id)
int hfi_read_message(uint32_t *pmsg, uint8_t q_id,
	uint32_t *words_read)
{
	struct hfi_qtbl *q_tbl_ptr;
	struct hfi_q_hdr *q;
	uint32_t new_read_idx, size_in_words, word_diff, temp;
	uint32_t *read_q, *read_ptr, *write_ptr;
	int64_t rc = 0;
	int rc = 0;

	if (!pmsg) {
		CAM_ERR(CAM_HFI, "Invalid msg");
@@ -202,7 +203,7 @@ int64_t hfi_read_message(uint32_t *pmsg, uint8_t q_id)
	}

	q->qhdr_read_idx = new_read_idx;
	rc = size_in_words;
	*words_read = size_in_words;
err:
	mutex_unlock(&hfi_msg_q_mutex);
	return rc;
+18 −19
Original line number Diff line number Diff line
@@ -1150,11 +1150,12 @@ static void cam_icp_mgr_process_dbg_buf(void)
{
	uint32_t *msg_ptr = NULL, *pkt_ptr = NULL;
	struct hfi_msg_debug *dbg_msg;
	int64_t read_len, size_processed = 0;
	uint32_t read_len, size_processed = 0;
	char *dbg_buf;
	int rc = 0;

	read_len = hfi_read_message(icp_hw_mgr.dbg_buf, Q_DBG);
	if (read_len < 0)
	rc = hfi_read_message(icp_hw_mgr.dbg_buf, Q_DBG, &read_len);
	if (rc)
		return;

	msg_ptr = (uint32_t *)icp_hw_mgr.dbg_buf;
@@ -1179,7 +1180,8 @@ static void cam_icp_mgr_process_dbg_buf(void)

static int cam_icp_process_msg_pkt_type(
	struct cam_icp_hw_mgr *hw_mgr,
	uint32_t *msg_ptr)
	uint32_t *msg_ptr,
	uint32_t *msg_processed_len)
{
	int rc = 0;
	int size_processed = 0;
@@ -1230,19 +1232,17 @@ static int cam_icp_process_msg_pkt_type(
		break;
	}

	if (rc)
	*msg_processed_len = size_processed;
	return rc;

	return size_processed;
}

static int32_t cam_icp_mgr_process_msg(void *priv, void *data)
{
	int64_t read_len, msg_processed_len;
	int rc = 0;
	uint32_t read_len, msg_processed_len;
	uint32_t *msg_ptr = NULL;
	struct hfi_msg_work_data *task_data;
	struct cam_icp_hw_mgr *hw_mgr;
	int rc = 0;

	if (!data || !priv) {
		CAM_ERR(CAM_ICP, "Invalid data");
@@ -1252,25 +1252,24 @@ static int32_t cam_icp_mgr_process_msg(void *priv, void *data)
	task_data = data;
	hw_mgr = priv;

	read_len = hfi_read_message(icp_hw_mgr.msg_buf, Q_MSG);
	if (read_len < 0) {
		rc = read_len;
	rc = hfi_read_message(icp_hw_mgr.msg_buf, Q_MSG, &read_len);
	if (rc) {
		CAM_DBG(CAM_ICP, "Unable to read msg q");
	} else {
		read_len = read_len << BYTE_WORD_SHIFT;
		msg_ptr = (uint32_t *)icp_hw_mgr.msg_buf;
		while (true) {
			msg_processed_len = cam_icp_process_msg_pkt_type(
			hw_mgr, msg_ptr);
			if (msg_processed_len < 0) {
				rc = msg_processed_len;
			rc = cam_icp_process_msg_pkt_type(hw_mgr, msg_ptr,
				&msg_processed_len);
			if (rc)
				return rc;
			}

			read_len -= msg_processed_len;
			if (read_len > 0)
			if (read_len > 0) {
				msg_ptr += (msg_processed_len >>
				BYTE_WORD_SHIFT);
				msg_processed_len = 0;
			}
			else
				break;
		}