aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSudeep Holla <sudeep.holla@arm.com>2017-04-27 10:20:37 -0400
committerSudeep Holla <sudeep.holla@arm.com>2017-06-05 06:14:35 -0400
commitc0f2e21953324def9e2f8394406b557d7cb5af64 (patch)
tree2412ddb8b0b7ed4999fd488c88930a027bddbfbc
parent45ca7df7c345465dbd2426a33012c9c33d27de62 (diff)
cpufreq: scpi: use new scpi_ops functions to remove duplicate code
scpi_ops now provide APIs to get the transition_latency and to add OPPs to the devices making those logic redundant here. This patch makes use of those APIs and removes the redundant code in this driver. Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
-rw-r--r--drivers/cpufreq/scpi-cpufreq.c38
1 files changed, 6 insertions, 32 deletions
diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
index ea7a4e1b68c2..8de2364b5995 100644
--- a/drivers/cpufreq/scpi-cpufreq.c
+++ b/drivers/cpufreq/scpi-cpufreq.c
@@ -30,46 +30,20 @@
30 30
31static struct scpi_ops *scpi_ops; 31static struct scpi_ops *scpi_ops;
32 32
33static struct scpi_dvfs_info *scpi_get_dvfs_info(struct device *cpu_dev)
34{
35 int domain = topology_physical_package_id(cpu_dev->id);
36
37 if (domain < 0)
38 return ERR_PTR(-EINVAL);
39 return scpi_ops->dvfs_get_info(domain);
40}
41
42static int scpi_get_transition_latency(struct device *cpu_dev) 33static int scpi_get_transition_latency(struct device *cpu_dev)
43{ 34{
44 struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev); 35 return scpi_ops->get_transition_latency(cpu_dev);
45
46 if (IS_ERR(info))
47 return PTR_ERR(info);
48 return info->latency;
49} 36}
50 37
51static int scpi_init_opp_table(const struct cpumask *cpumask) 38static int scpi_init_opp_table(const struct cpumask *cpumask)
52{ 39{
53 int idx, ret; 40 int ret;
54 struct scpi_opp *opp;
55 struct device *cpu_dev = get_cpu_device(cpumask_first(cpumask)); 41 struct device *cpu_dev = get_cpu_device(cpumask_first(cpumask));
56 struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev);
57
58 if (IS_ERR(info))
59 return PTR_ERR(info);
60
61 if (!info->opps)
62 return -EIO;
63 42
64 for (opp = info->opps, idx = 0; idx < info->count; idx++, opp++) { 43 ret = scpi_ops->add_opps_to_device(cpu_dev);
65 ret = dev_pm_opp_add(cpu_dev, opp->freq, opp->m_volt * 1000); 44 if (ret) {
66 if (ret) { 45 dev_warn(cpu_dev, "failed to add opps to the device\n");
67 dev_warn(cpu_dev, "failed to add opp %uHz %umV\n", 46 return ret;
68 opp->freq, opp->m_volt);
69 while (idx-- > 0)
70 dev_pm_opp_remove(cpu_dev, (--opp)->freq);
71 return ret;
72 }
73 } 47 }
74 48
75 ret = dev_pm_opp_set_sharing_cpus(cpu_dev, cpumask); 49 ret = dev_pm_opp_set_sharing_cpus(cpu_dev, cpumask);