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

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

Merge "diag: Change IPC logging debug bit mask through debugfs"

parents 159789f9 5a0ef7fe
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;
@@ -678,6 +680,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)
@@ -926,6 +959,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;
@@ -974,6 +1011,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);