From 03e7659014b7f5f7afc8bed8f1a40b2570363218 Mon Sep 17 00:00:00 2001 From: Tapas Kumar Kundu Date: Thu, 10 Mar 2016 15:15:23 -0800 Subject: [PATCH] soc: qcom: msm_perf: Replace obsolete cpulist_scnprintf api Replace obsolete cpulist_scnprintf api with cpumap_print_to_pagebuf for kernel-4.4 Signed-off-by: Tapas Kumar Kundu --- drivers/soc/qcom/msm_performance.c | 53 ++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/drivers/soc/qcom/msm_performance.c b/drivers/soc/qcom/msm_performance.c index 71f2810713aa..7f03ce4518a6 100644 --- a/drivers/soc/qcom/msm_performance.c +++ b/drivers/soc/qcom/msm_performance.c @@ -184,6 +184,7 @@ static struct input_handler *handler; #define CLUSTER_0_THRESHOLD_FREQ 147000 #define CLUSTER_1_THRESHOLD_FREQ 190000 #define INPUT_EVENT_CNT_THRESHOLD 15 +#define MAX_LENGTH_CPU_STRING 256 @@ -307,20 +308,33 @@ static int set_managed_cpus(const char *buf, const struct kernel_param *kp) static int get_managed_cpus(char *buf, const struct kernel_param *kp) { - int i, cnt = 0; + int i, cnt = 0, total_cnt = 0; + char tmp[MAX_LENGTH_CPU_STRING]; if (!clusters_inited) return cnt; for (i = 0; i < num_clusters; i++) { - cnt += cpulist_scnprintf(buf + cnt, PAGE_SIZE - cnt, + cnt = cpumap_print_to_pagebuf(true, buf, managed_clusters[i]->cpus); - if ((i + 1) >= num_clusters) + if ((i + 1) < num_clusters && + (total_cnt + cnt + 1) <= MAX_LENGTH_CPU_STRING) { + snprintf(tmp + total_cnt, cnt, "%s", buf); + tmp[cnt-1] = ':'; + tmp[cnt] = '\0'; + total_cnt += cnt; + } else if ((i + 1) == num_clusters && + (total_cnt + cnt) <= MAX_LENGTH_CPU_STRING) { + snprintf(tmp + total_cnt, cnt, "%s", buf); + total_cnt += cnt; + } else { + pr_err("invalid string for managed_cpu:%s%s\n", tmp, + buf); break; - cnt += snprintf(buf + cnt, PAGE_SIZE - cnt, ":"); + } } - - return cnt; + snprintf(buf, PAGE_SIZE, "%s", tmp); + return total_cnt; } static const struct kernel_param_ops param_ops_managed_cpus = { @@ -332,7 +346,8 @@ device_param_cb(managed_cpus, ¶m_ops_managed_cpus, NULL, 0644); /* Read-only node: To display all the online managed CPUs */ static int get_managed_online_cpus(char *buf, const struct kernel_param *kp) { - int i, cnt = 0; + int i, cnt = 0, total_cnt = 0; + char tmp[MAX_LENGTH_CPU_STRING]; struct cpumask tmp_mask; struct cluster *i_cl; @@ -346,15 +361,25 @@ static int get_managed_online_cpus(char *buf, const struct kernel_param *kp) cpumask_complement(&tmp_mask, i_cl->offlined_cpus); cpumask_and(&tmp_mask, i_cl->cpus, &tmp_mask); - cnt += cpulist_scnprintf(buf + cnt, PAGE_SIZE - cnt, - &tmp_mask); - - if ((i + 1) >= num_clusters) + cnt = cpumap_print_to_pagebuf(true, buf, &tmp_mask); + if ((i + 1) < num_clusters && + (total_cnt + cnt + 1) <= MAX_LENGTH_CPU_STRING) { + snprintf(tmp + total_cnt, cnt, "%s", buf); + tmp[cnt-1] = ':'; + tmp[cnt] = '\0'; + total_cnt += cnt; + } else if ((i + 1) == num_clusters && + (total_cnt + cnt) <= MAX_LENGTH_CPU_STRING) { + snprintf(tmp + total_cnt, cnt, "%s", buf); + total_cnt += cnt; + } else { + pr_err("invalid string for managed_cpu:%s%s\n", tmp, + buf); break; - cnt += snprintf(buf + cnt, PAGE_SIZE - cnt, ":"); + } } - - return cnt; + snprintf(buf, PAGE_SIZE, "%s", tmp); + return total_cnt; } static const struct kernel_param_ops param_ops_managed_online_cpus = {