diff mbox series

[2/2] cpufreq: scpi: use new scpi_ops functions to remove duplicate code

Message ID 1493371296-12465-2-git-send-email-sudeep.holla@arm.com
State Accepted
Commit c0f2e21953324def9e2f8394406b557d7cb5af64
Headers show
Series [1/2] firmware: arm_scpi: add support to populate OPPs and get transition latency | expand

Commit Message

Sudeep Holla April 28, 2017, 9:21 a.m. UTC
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 redunant code in
this driver.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

---
 drivers/cpufreq/scpi-cpufreq.c | 38 ++++++--------------------------------
 1 file changed, 6 insertions(+), 32 deletions(-)

-- 
2.7.4

Comments

Viresh Kumar April 28, 2017, 9:24 a.m. UTC | #1
On 28-04-17, 10:21, Sudeep Holla wrote:
> 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 redunant code in

> this driver.

> 

> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>

> Cc: Viresh Kumar <viresh.kumar@linaro.org>

> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

> ---

>  drivers/cpufreq/scpi-cpufreq.c | 38 ++++++--------------------------------

>  1 file changed, 6 insertions(+), 32 deletions(-)


Acked-by: Viresh Kumar <viresh.kumar@linaro.org>


-- 
viresh
Rafael J. Wysocki April 28, 2017, 9:34 p.m. UTC | #2
On Friday, April 28, 2017 02:54:56 PM Viresh Kumar wrote:
> On 28-04-17, 10:21, Sudeep Holla wrote:

> > 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 redunant code in

> > this driver.

> > 

> > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>

> > Cc: Viresh Kumar <viresh.kumar@linaro.org>

> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

> > ---

> >  drivers/cpufreq/scpi-cpufreq.c | 38 ++++++--------------------------------

> >  1 file changed, 6 insertions(+), 32 deletions(-)

> 

> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

> 

> 


OK

Sudeep, please route this through ARM.

Thanks,
Rafael
Sudeep Holla May 2, 2017, 8:57 a.m. UTC | #3
On 28/04/17 22:34, Rafael J. Wysocki wrote:
> On Friday, April 28, 2017 02:54:56 PM Viresh Kumar wrote:

>> On 28-04-17, 10:21, Sudeep Holla wrote:

>>> 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 redunant code in

>>> this driver.

>>>

>>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>

>>> Cc: Viresh Kumar <viresh.kumar@linaro.org>

>>> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

>>> ---

>>>  drivers/cpufreq/scpi-cpufreq.c | 38 ++++++--------------------------------

>>>  1 file changed, 6 insertions(+), 32 deletions(-)

>>

>> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

>>

>>

> 

> OK

> 

> Sudeep, please route this through ARM.


Sure, thanks.

-- 
Regards,
Sudeep
diff mbox series

Patch

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 @@ 
 
 static struct scpi_ops *scpi_ops;
 
-static struct scpi_dvfs_info *scpi_get_dvfs_info(struct device *cpu_dev)
-{
-	int domain = topology_physical_package_id(cpu_dev->id);
-
-	if (domain < 0)
-		return ERR_PTR(-EINVAL);
-	return scpi_ops->dvfs_get_info(domain);
-}
-
 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;
+	return scpi_ops->get_transition_latency(cpu_dev);
 }
 
 static int scpi_init_opp_table(const struct cpumask *cpumask)
 {
-	int idx, ret;
-	struct scpi_opp *opp;
+	int ret;
 	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))
-		return PTR_ERR(info);
-
-	if (!info->opps)
-		return -EIO;
 
-	for (opp = info->opps, idx = 0; idx < info->count; idx++, opp++) {
-		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);
-			while (idx-- > 0)
-				dev_pm_opp_remove(cpu_dev, (--opp)->freq);
-			return ret;
-		}
+	ret = scpi_ops->add_opps_to_device(cpu_dev);
+	if (ret) {
+		dev_warn(cpu_dev, "failed to add opps to the device\n");
+		return ret;
 	}
 
 	ret = dev_pm_opp_set_sharing_cpus(cpu_dev, cpumask);