From 0e6644289c1345e02f09e2efbd74fb9fcbcab262 Mon Sep 17 00:00:00 2001 From: Eunseok Choi Date: Fri, 16 Jun 2017 20:08:53 +0900 Subject: [PATCH] [COMMON] thermal: samsung: clean up acpm tmu debug Change-Id: I216da414e8d7618fa201d55ea548249f73f69483 Signed-off-by: Eunseok Choi --- drivers/thermal/samsung/exynos_tmu.c | 69 ++++++++-------------------- 1 file changed, 20 insertions(+), 49 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 7e94ccdb23d3..80e4d496f2e8 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -2396,63 +2396,34 @@ static void exynos_acpm_tmu_test_cp_call(bool mode) } } -static ssize_t test_cp_call_write(struct file *file, const char __user *user_buf, - size_t count, loff_t *ppos) +static int emul_call_get(void *data, unsigned long long *val) { - ssize_t len; - char buf[32]; - - len = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); - if (len < 0) - return len; + *val = exynos_acpm_tmu_is_test_mode(); - buf[len] = '\0'; - - if (buf[0] == '1' && exynos_acpm_tmu_is_test_mode() == false) { - exynos_acpm_tmu_set_test_mode(true); - exynos_acpm_tmu_test_cp_call(true); - } else if (buf[0] == '0' && exynos_acpm_tmu_is_test_mode() == true) { - exynos_acpm_tmu_set_test_mode(false); - exynos_acpm_tmu_test_cp_call(false); - } else - return -EINVAL; - - return len; + return 0; } -static const struct file_operations test_cp_call_ops = { - .open = simple_open, - .write = test_cp_call_write, - .llseek = default_llseek, -}; - -static ssize_t acpm_tmu_log_write(struct file *file, const char __user *user_buf, - size_t count, loff_t *ppos) +static int emul_call_set(void *data, unsigned long long val) { - ssize_t len; - char buf[32]; + int status = exynos_acpm_tmu_is_test_mode(); - len = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); - if (len < 0) - return len; + if ((val == 0 || val == 1) && (val != status)) { + exynos_acpm_tmu_set_test_mode(val); + exynos_acpm_tmu_test_cp_call(val); + } - buf[len] = '\0'; + return 0; +} +DEFINE_SIMPLE_ATTRIBUTE(emul_call_fops, emul_call_get, emul_call_set, "%llu\n"); - if (buf[0] == '1') - exynos_acpm_tmu_log(true); - else if (buf[0] == '0') - exynos_acpm_tmu_log(false); - else - return -EINVAL; +static int log_print_set(void *data, unsigned long long val) +{ + if (val == 0 || val == 1) + exynos_acpm_tmu_log(val); - return len; + return 0; } - -static const struct file_operations acpm_tmu_log_ops = { - .open = simple_open, - .write = acpm_tmu_log_write, - .llseek = default_llseek, -}; +DEFINE_SIMPLE_ATTRIBUTE(log_print_fops, NULL, log_print_set, "%llu\n"); static ssize_t ipc_dump1_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) @@ -2522,8 +2493,8 @@ static int exynos_thermal_create_debugfs(void) } #ifdef CONFIG_EXYNOS_ACPM_THERMAL - debugfs_create_file("test_cp_call", 0x200, debugfs_root, NULL, &test_cp_call_ops); - debugfs_create_file("acpm_tmu_log", 0x200, debugfs_root, NULL, &acpm_tmu_log_ops); + debugfs_create_file("emul_call", 0644, debugfs_root, NULL, &emul_call_fops); + debugfs_create_file("log_print", 0644, debugfs_root, NULL, &log_print_fops); debugfs_create_file("ipc_dump1", 0644, debugfs_root, NULL, &ipc_dump1_fops); debugfs_create_file("ipc_dump2", 0644, debugfs_root, NULL, &ipc_dump2_fops); #endif -- 2.20.1