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

Commit 11ff9869 authored by Ankit Gupta's avatar Ankit Gupta
Browse files

i2c-msm-v2: correct the scan algorithm



Applied correction to the scan algorithm including:
- remove stop tag after a write buffer which is not the last
  one for the message set.
- normalize the start is required boolean to 0 or one before
  it is used as an index to a lookup table.
- correct the detection condition for last buffer which is a
  rx.

Change-Id: Ide1eb4f63cb2950cfd6e402d961c63fae1dd2f21
Signed-off-by: default avatarAnkit Gupta <ankgupta@codeaurora.org>
parent d22d8efb
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -874,6 +874,8 @@ static struct i2c_msm_tag i2c_msm_tag_create(bool is_high_speed,
	u8 slave_addr)
{
	struct i2c_msm_tag tag;
	/* Normalize booleans to 1 or 0 */
	start_req = start_req ? 1 : 0;
	is_last_buf = is_last_buf ? 1 : 0;
	is_rx = is_rx ? 1 : 0;

@@ -3183,7 +3185,8 @@ static bool i2c_msm_xfer_buf_is_last(struct i2c_msm_ctrl *ctrl)
	struct i2c_msm_xfer_buf *cur_buf = &ctrl->xfer.cur_buf;
	struct i2c_msg *cur_msg = ctrl->xfer.msgs + cur_buf->msg_idx;

	return (cur_buf->byte_idx + ctrl->ver.max_buf_size) >= cur_msg->len;
	return i2c_msm_xfer_msg_is_last(ctrl) &&
		((cur_buf->byte_idx + ctrl->ver.max_buf_size) >= cur_msg->len);
}

static void i2c_msm_xfer_create_cur_tag(struct i2c_msm_ctrl *ctrl,
@@ -3364,7 +3367,7 @@ static void i2c_msm_xfer_scan(struct i2c_msm_ctrl *ctrl)
		xfer->rx_ovrhd_cnt += cur_buf->in_tag.len;
		xfer->tx_ovrhd_cnt += cur_buf->out_tag.len;

		if (cur_buf->is_last)
		if (i2c_msm_xfer_msg_is_last(ctrl))
			xfer->last_is_rx = cur_buf->is_rx;
	}
	ctrl->xfer.cur_buf = first_buf;