From 15a734e879e68f10b941290653a3175b128ad9d3 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Mon, 30 Mar 2015 18:35:32 -0700 Subject: [PATCH] soc: qcom: Add infrastructure to test service locator Add debugfs node based infrastructure to test service locator Change-Id: I37cb319638ce5b6285b2f2ff4386fd92cbda83fd Signed-off-by: Pushkar Joshi --- drivers/soc/qcom/service-locator.c | 69 ++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/drivers/soc/qcom/service-locator.c b/drivers/soc/qcom/service-locator.c index fae8a6f96d70..49fce3602cd4 100644 --- a/drivers/soc/qcom/service-locator.c +++ b/drivers/soc/qcom/service-locator.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -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) { - class_register(&service_locator_class); + 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 void service_locator_exit(void) +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 __exit service_locator_exit(void) { class_unregister(&service_locator_class); + debugfs_remove(test_servloc_file); } module_init(service_locator_init);