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

Commit 5a0ef7fe authored by Ravi Aravamudhan's avatar Ravi Aravamudhan
Browse files

diag: Change IPC logging debug bit mask through debugfs



Diag driver uses IPC logging to log certain events in the driver.
Make the bit mask that governs which logs are being logged
configurable through debugfs.

Change-Id: Ieb1906992c8fcff9cffc2339323e0d7b10f3356f
Signed-off-by: default avatarRavi Aravamudhan <aravamud@codeaurora.org>
parent abc6c3ce
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/debugfs.h>
#include <linux/atomic.h>
#include <linux/uaccess.h>
#include "diagchar.h"
#include "diagfwd.h"
#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
@@ -30,6 +31,7 @@
#include "diagfwd_smd.h"
#include "diagfwd_socket.h"
#include "diag_debugfs.h"
#include "diag_ipc_logging.h"

#define DEBUG_BUF_SIZE	4096
static struct dentry *diag_dbgfs_dent;
@@ -672,6 +674,37 @@ static ssize_t diag_dbgfs_read_socketinfo(struct file *file, char __user *ubuf,
	return ret;
}

static ssize_t diag_dbgfs_write_debug(struct file *fp, const char __user *buf,
				      size_t count, loff_t *ppos)
{
	const int size = 10;
	unsigned char cmd[size];
	long value = 0;
	int len = 0;

	if (count < 1)
		return -EINVAL;

	len = (count < (size - 1)) ? count : size - 1;
	if (copy_from_user(cmd, buf, len))
		return -EFAULT;

	cmd[len] = 0;
	if (cmd[len-1] == '\n') {
		cmd[len-1] = 0;
		len--;
	}

	if (kstrtol(cmd, 10, &value))
		return -EINVAL;

	if (value < 0)
		return -EINVAL;

	diag_debug_mask = (uint16_t)value;
	return count;
}

#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
static ssize_t diag_dbgfs_read_hsicinfo(struct file *file, char __user *ubuf,
					size_t count, loff_t *ppos)
@@ -920,6 +953,10 @@ const struct file_operations diag_dbgfs_power_ops = {
	.read = diag_dbgfs_read_power,
};

const struct file_operations diag_dbgfs_debug_ops = {
	.write = diag_dbgfs_write_debug
};

int diag_debugfs_init(void)
{
	struct dentry *entry = NULL;
@@ -968,6 +1005,11 @@ int diag_debugfs_init(void)
	if (!entry)
		goto err;

	entry = debugfs_create_file("debug", 0444, diag_dbgfs_dent, 0,
				    &diag_dbgfs_debug_ops);
	if (!entry)
		goto err;

#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
	entry = debugfs_create_file("bridge", 0444, diag_dbgfs_dent, 0,
				    &diag_dbgfs_bridge_ops);