From 863981e96738983919de841ec669e157e6bdaeb0 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Sun, 11 Sep 2016 04:34:46 -0300 Subject: Linux-libre 4.7.1-gnu --- drivers/cpufreq/scpi-cpufreq.c | 47 ++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'drivers/cpufreq/scpi-cpufreq.c') diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c index de5e89b2e..e8a7bf57b 100644 --- a/drivers/cpufreq/scpi-cpufreq.c +++ b/drivers/cpufreq/scpi-cpufreq.c @@ -18,6 +18,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -38,10 +39,20 @@ static struct scpi_dvfs_info *scpi_get_dvfs_info(struct device *cpu_dev) return scpi_ops->dvfs_get_info(domain); } -static int scpi_opp_table_ops(struct device *cpu_dev, bool remove) +static int scpi_get_transition_latency(struct device *cpu_dev) { - int idx, ret = 0; + struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev); + + if (IS_ERR(info)) + return PTR_ERR(info); + return info->latency; +} + +static int scpi_init_opp_table(const struct cpumask *cpumask) +{ + int idx, ret; struct scpi_opp *opp; + struct device *cpu_dev = get_cpu_device(cpumask_first(cpumask)); struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev); if (IS_ERR(info)) @@ -51,11 +62,7 @@ static int scpi_opp_table_ops(struct device *cpu_dev, bool remove) return -EIO; for (opp = info->opps, idx = 0; idx < info->count; idx++, opp++) { - if (remove) - dev_pm_opp_remove(cpu_dev, opp->freq); - else - ret = dev_pm_opp_add(cpu_dev, opp->freq, - opp->m_volt * 1000); + ret = dev_pm_opp_add(cpu_dev, opp->freq, opp->m_volt * 1000); if (ret) { dev_warn(cpu_dev, "failed to add opp %uHz %umV\n", opp->freq, opp->m_volt); @@ -64,33 +71,19 @@ static int scpi_opp_table_ops(struct device *cpu_dev, bool remove) return ret; } } - return ret; -} -static int scpi_get_transition_latency(struct device *cpu_dev) -{ - struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev); - - if (IS_ERR(info)) - return PTR_ERR(info); - return info->latency; -} - -static int scpi_init_opp_table(struct device *cpu_dev) -{ - return scpi_opp_table_ops(cpu_dev, false); -} - -static void scpi_free_opp_table(struct device *cpu_dev) -{ - scpi_opp_table_ops(cpu_dev, true); + ret = dev_pm_opp_set_sharing_cpus(cpu_dev, cpumask); + if (ret) + dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", + __func__, ret); + return ret; } static struct cpufreq_arm_bL_ops scpi_cpufreq_ops = { .name = "scpi", .get_transition_latency = scpi_get_transition_latency, .init_opp_table = scpi_init_opp_table, - .free_opp_table = scpi_free_opp_table, + .free_opp_table = dev_pm_opp_cpumask_remove_table, }; static int scpi_cpufreq_probe(struct platform_device *pdev) -- cgit v1.2.3-54-g00ecf