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

Commit d167001f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm:rpm-log: add the mutex to protect read opertion"

parents 8fd856a9 5c5fc156
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ struct msm_rpm_log_buffer {
	char *data;
	u32 len;
	u32 pos;
	struct mutex mutex;
	u32 max_len;
	u32 read_idx;
	struct msm_rpm_log_platform_data *pdata;
@@ -216,6 +217,7 @@ static ssize_t msm_rpm_log_file_read(struct file *file, char __user *bufu,
	if (!access_ok(VERIFY_WRITE, bufu, count))
		return -EFAULT;

	mutex_lock(&buf->mutex);
	/* check for more messages if local buffer empty */
	if (buf->pos == buf->len) {
		buf->pos = 0;
@@ -224,6 +226,7 @@ static ssize_t msm_rpm_log_file_read(struct file *file, char __user *bufu,
	}

	if ((file->f_flags & O_NONBLOCK) && buf->len == 0)
		mutex_unlock(&buf->mutex);
		return -EAGAIN;

	/* loop until new messages arrive */
@@ -239,6 +242,7 @@ static ssize_t msm_rpm_log_file_read(struct file *file, char __user *bufu,

	remaining = __copy_to_user(bufu, &(buf->data[buf->pos]), out_len);
	buf->pos += out_len - remaining;
	mutex_unlock(&buf->mutex);

	return out_len - remaining;
}
@@ -285,6 +289,7 @@ static int msm_rpm_log_file_open(struct inode *inode, struct file *file)
	buf->pdata = pdata;
	buf->len = 0;
	buf->pos = 0;
	mutex_init(&buf->mutex);
	buf->max_len = PRINTED_LENGTH(pdata->log_len);
	buf->read_idx = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_INDICES,
					 MSM_RPM_LOG_HEAD);