From: Lukasz Luba <lukasz.luba@arm.com>
To: linux-pm@vger.kernel.org
Cc: rui.zhang@intel.com, edubezval@gmail.com, javi.merino@kernel.org,
chris.diamand@arm.com, lukasz.luba@arm.com
Subject: [PATCH v3 1/3] thermal: devfreq_cooling: refactor code and add get_voltage function
Date: Thu, 4 May 2017 12:34:31 +0100 [thread overview]
Message-ID: <1493897673-1826-2-git-send-email-lukasz.luba@arm.com> (raw)
In-Reply-To: <1493897673-1826-1-git-send-email-lukasz.luba@arm.com>
Move the code which gets the voltage for a given frequency.
This code will be resused in few places.
Acked-by: Javi Merino <javi.merino@kernel.org>
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
drivers/thermal/devfreq_cooling.c | 45 ++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 17 deletions(-)
diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
index 4bf4ad5..af9d328 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c
@@ -164,27 +164,12 @@ static int devfreq_cooling_set_cur_state(struct thermal_cooling_device *cdev,
return THERMAL_CSTATE_INVALID;
}
-/**
- * get_static_power() - calculate the static power
- * @dfc: Pointer to devfreq cooling device
- * @freq: Frequency in Hz
- *
- * Calculate the static power in milliwatts using the supplied
- * get_static_power(). The current voltage is calculated using the
- * OPP library. If no get_static_power() was supplied, assume the
- * static power is negligible.
- */
-static unsigned long
-get_static_power(struct devfreq_cooling_device *dfc, unsigned long freq)
+static unsigned long get_voltage(struct devfreq *df, unsigned long freq)
{
- struct devfreq *df = dfc->devfreq;
struct device *dev = df->dev.parent;
unsigned long voltage;
struct dev_pm_opp *opp;
- if (!dfc->power_ops->get_static_power)
- return 0;
-
opp = dev_pm_opp_find_freq_exact(dev, freq, true);
if (PTR_ERR(opp) == -ERANGE)
opp = dev_pm_opp_find_freq_exact(dev, freq, false);
@@ -202,9 +187,35 @@ static int devfreq_cooling_set_cur_state(struct thermal_cooling_device *cdev,
dev_err_ratelimited(dev,
"Failed to get voltage for frequency %lu\n",
freq);
- return 0;
}
+ return voltage;
+}
+
+/**
+ * get_static_power() - calculate the static power
+ * @dfc: Pointer to devfreq cooling device
+ * @freq: Frequency in Hz
+ *
+ * Calculate the static power in milliwatts using the supplied
+ * get_static_power(). The current voltage is calculated using the
+ * OPP library. If no get_static_power() was supplied, assume the
+ * static power is negligible.
+ */
+static unsigned long
+get_static_power(struct devfreq_cooling_device *dfc, unsigned long freq)
+{
+ struct devfreq *df = dfc->devfreq;
+ unsigned long voltage;
+
+ if (!dfc->power_ops->get_static_power)
+ return 0;
+
+ voltage = get_voltage(df, freq);
+
+ if (voltage == 0)
+ return 0;
+
return dfc->power_ops->get_static_power(df, voltage);
}
--
1.9.1
next prev parent reply other threads:[~2017-05-04 11:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-04 11:34 [PATCH v3 0/3] devfreq_cooling: let the driver supply the Lukasz Luba
2017-05-04 11:34 ` Lukasz Luba [this message]
2017-05-04 11:34 ` [PATCH v3 2/3] thermal: devfreq_cooling: add new interface for direct power read Lukasz Luba
2017-05-04 11:34 ` [PATCH v3 3/3] trace: thermal: add another parameter 'power' to the tracing function Lukasz Luba
2017-05-09 9:48 ` [PATCH v3 0/3] devfreq_cooling: let the driver supply the Lukasz Luba
2017-05-10 1:14 ` Zhang Rui
2017-05-10 7:47 ` Lukasz Luba
-- strict thread matches above, loose matches on Subject: below --
2017-03-14 13:06 [PATCH v3] devfreq_cooling: let the driver supply the real power every time we need it Lukasz Luba
2017-03-14 13:06 ` [PATCH v3 1/3] thermal: devfreq_cooling: refactor code and add get_voltage function Lukasz Luba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1493897673-1826-2-git-send-email-lukasz.luba@arm.com \
--to=lukasz.luba@arm.com \
--cc=chris.diamand@arm.com \
--cc=edubezval@gmail.com \
--cc=javi.merino@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox