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

Commit 8096c972 authored by Pushkar Joshi's avatar Pushkar Joshi
Browse files

soc: qcom: Add infrastructure to test service locator



Add debugfs node based infrastructure to test service locator

Change-Id: I37cb319638ce5b6285b2f2ff4386fd92cbda83fd
Signed-off-by: default avatarPushkar Joshi <pushkarj@codeaurora.org>
parent 25c311d7
Loading
Loading
Loading
Loading
+65 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/workqueue.h>
#include <linux/debugfs.h>

#include <soc/qcom/msm_qmi_interface.h>
#include <soc/qcom/service-locator.h>
@@ -447,15 +448,77 @@ int find_subsys(const char *pd_path, char *subsys)
}
EXPORT_SYMBOL(find_subsys);

static int service_locator_init(void)
static struct pd_qmi_client_data test_data;

static ssize_t show_servloc(struct seq_file *f, void *unused)
{
	int rc = 0, i = 0;
	char subsys[QMI_SERVREG_LOC_NAME_LENGTH_V01];

	rc = get_service_location(&test_data);
	if (rc) {
		seq_printf(f, "Failed to get process domain!, rc = %d\n", rc);
		return -EIO;
	}

	seq_printf(f, "Service Name: %s\tTotal Domains: %d\n",
			test_data.service_name, test_data.total_domains);
	for (i = 0; i < test_data.total_domains; i++) {
		seq_printf(f, "Instance ID: %d\t ",
			test_data.domain_list[i].instance_id);
		seq_printf(f, "Domain Name: %s\n",
			test_data.domain_list[i].name);
		rc = find_subsys(test_data.domain_list[i].name, subsys);
		if (rc < 0)
			seq_printf(f, "No valid subsys found for %s!\n",
						test_data.domain_list[i].name);
		else
			seq_printf(f, "Subsys: %s\n", subsys);
	}
	return 0;
}

static ssize_t store_servloc(struct file *fp, const char __user *buf,
						size_t count, loff_t *unused)
{
	if (!buf)
		return -EIO;
	snprintf(test_data.service_name, sizeof(test_data.service_name),
			"%.*s", (int) min((size_t)count - 1,
			(sizeof(test_data.service_name) - 1)), buf);
	return count;
}

static int servloc_open(struct inode *inode, struct file *file)
{
	return single_open(file, (void *)show_servloc, inode->i_private);
}

static const struct file_operations servloc_fops = {
	.open		= servloc_open,
	.read		= seq_read,
	.write		= store_servloc,
	.llseek		= seq_lseek,
	.release	= seq_release,
};

static struct dentry *test_servloc_file;

static int __init service_locator_init(void)
{
	class_register(&service_locator_class);
	test_servloc_file = debugfs_create_file("test_servloc",
				S_IRUGO | S_IWUSR, NULL, NULL,
				&servloc_fops);
	if (!test_servloc_file)
		pr_err("Could not create test_servloc debugfs entry!");
	return 0;
}

static void service_locator_exit(void)
static void __exit service_locator_exit(void)
{
	class_unregister(&service_locator_class);
	debugfs_remove(test_servloc_file);
}

module_init(service_locator_init);