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

Commit 844ed10f authored by Manoj Prabhu B's avatar Manoj Prabhu B
Browse files

diag: Modify socket and rpmsg debug information output



Due to small buffer size and increased peripheral information and
associated socket and rpmsg information, output of socketinfo
and rpmsginfo in debugfs is not proper. Modified the way debug
information is output to make use of small buffer.

Change-Id: Ie39a5ca8e1c1ef53b7e77ec44c77fe5c6706f2a1
Signed-off-by: default avatarManoj Prabhu B <bmanoj@codeaurora.org>
parent f7be1951
Loading
Loading
Loading
Loading
+128 −139
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2020, The Linux Foundation. All rights reserved.
 */

#ifdef CONFIG_DEBUG_FS
@@ -480,7 +480,6 @@ static ssize_t diag_dbgfs_read_socketinfo(struct file *file, char __user *ubuf,
	int i = 0;
	int j = 0;
	unsigned int buf_size;
	unsigned int bytes_remaining = 0;
	unsigned int bytes_written = 0;
	unsigned int bytes_in_buffer = 0;
	struct diag_socket_info *info = NULL;
@@ -499,8 +498,8 @@ static ssize_t diag_dbgfs_read_socketinfo(struct file *file, char __user *ubuf,
	}

	buf_size = ksize(buf);
	bytes_remaining = buf_size;
	for (i = 0; i < NUM_TYPES; i++) {

	i = diag_dbgfs_socketinfo_index;
	for (j = 0; j < NUM_PERIPHERALS; j++) {
		switch (i) {
		case TYPE_DATA:
@@ -519,13 +518,13 @@ static ssize_t diag_dbgfs_read_socketinfo(struct file *file, char __user *ubuf,
			info = &socket_dci_cmd[j];
			break;
		default:
			kfree(buf);
			return -EINVAL;
		}

		fwd_ctxt = (struct diagfwd_info *)(info->fwd_ctxt);

		bytes_written = scnprintf(buf+bytes_in_buffer,
				bytes_remaining,
			buf_size,
			"name\t\t:\t%s\n"
			"hdl\t\t:\t%pK\n"
			"inited\t\t:\t%d\n"
@@ -561,16 +560,13 @@ static ssize_t diag_dbgfs_read_socketinfo(struct file *file, char __user *ubuf,
			(fwd_ctxt) ?
			atomic_read(&fwd_ctxt->opened) : -1,
			(fwd_ctxt) ? fwd_ctxt->ch_open : -1);
			bytes_in_buffer += bytes_written;

			/* Check if there is room to add another table entry */
			bytes_remaining = buf_size - bytes_in_buffer;
		bytes_in_buffer += bytes_written;

			if (bytes_remaining < bytes_written)
				break;
	}
	}
	diag_dbgfs_socketinfo_index = i+1;

	diag_dbgfs_socketinfo_index += 1;

	*ppos = 0;
	ret = simple_read_from_buffer(ubuf, count, ppos, buf, bytes_in_buffer);

@@ -586,7 +582,6 @@ static ssize_t diag_dbgfs_read_rpmsginfo(struct file *file, char __user *ubuf,
	int i = 0;
	int j = 0;
	unsigned int buf_size;
	unsigned int bytes_remaining = 0;
	unsigned int bytes_written = 0;
	unsigned int bytes_in_buffer = 0;
	struct diag_rpmsg_info *info = NULL;
@@ -603,8 +598,7 @@ static ssize_t diag_dbgfs_read_rpmsginfo(struct file *file, char __user *ubuf,
		return -ENOMEM;

	buf_size = ksize(buf);
	bytes_remaining = buf_size;
	for (i = 0; i < NUM_TYPES; i++) {
	i = diag_dbgfs_rpmsginfo_index;
	for (j = 0; j < NUM_PERIPHERALS; j++) {
		switch (i) {
		case TYPE_DATA:
@@ -623,13 +617,13 @@ static ssize_t diag_dbgfs_read_rpmsginfo(struct file *file, char __user *ubuf,
			info = &rpmsg_dci_cmd[j];
			break;
		default:
			kfree(buf);
			return -EINVAL;
		}

		fwd_ctxt = (struct diagfwd_info *)(info->fwd_ctxt);

		bytes_written = scnprintf(buf+bytes_in_buffer,
				bytes_remaining,
			buf_size,
			"name\t\t:\t%s:\t%s\n"
			"hdl\t\t:\t%pK\n"
			"inited\t\t:\t%d\n"
@@ -664,16 +658,11 @@ static ssize_t diag_dbgfs_read_rpmsginfo(struct file *file, char __user *ubuf,
			(fwd_ctxt) ?
			atomic_read(&fwd_ctxt->opened) : -1,
			(fwd_ctxt) ? fwd_ctxt->ch_open : -1);
			bytes_in_buffer += bytes_written;

			/* Check if there is room to add another table entry */
			bytes_remaining = buf_size - bytes_in_buffer;

			if (bytes_remaining < bytes_written)
				break;
		}
		bytes_in_buffer += bytes_written;
	}
	diag_dbgfs_rpmsginfo_index = i+1;
	diag_dbgfs_rpmsginfo_index += 1;

	*ppos = 0;
	ret = simple_read_from_buffer(ubuf, count, ppos, buf, bytes_in_buffer);