From: "Pandruvada, Srinivas" <srinivas.pandruvada@intel.com>
To: "edubezval@gmail.com" <edubezval@gmail.com>,
"Zhang, Rui" <rui.zhang@intel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Subject: Re: [PATCHv2 2/3] thermal: rework core to allow emul_temp to be treated as regular temp
Date: Wed, 16 Mar 2016 00:09:36 +0000 [thread overview]
Message-ID: <1458083216.4486.42.camel@intel.com> (raw)
In-Reply-To: <1450379609-7826-3-git-send-email-edubezval@gmail.com>
On Thu, 2015-12-17 at 11:13 -0800, Eduardo Valentin wrote:
> Change the way we handle emul_temp. This is to allow
> emul_temp to be used as input to exercise thermal core
> properly. Now, even if .get_temp is not available,
> the emul_temp can be used to emulate temperature.
>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: linux-pm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> V1-> V2: fixed real_temp initial value.
> ---
> drivers/thermal/thermal_core.c | 33 ++++++++++++++++++++----------
> ---
> 1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/thermal/thermal_core.c
> b/drivers/thermal/thermal_core.c
> index 8fa82c0..a229c84 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -472,18 +472,25 @@ static void handle_thermal_trip(struct
> thermal_zone_device *tz, int trip)
> int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
> {
> int ret = -EINVAL;
> - int count;
> - int crit_temp = INT_MAX;
> - enum thermal_trip_type type;
> + int crit_temp = INT_MAX, real_temp = INT_MIN;
>
> - if (!tz || IS_ERR(tz) || !tz->ops->get_temp)
> - goto exit;
> + if (!tz || IS_ERR(tz))
> + return ret;
>
> mutex_lock(&tz->lock);
>
> - ret = tz->ops->get_temp(tz, temp);
> + /* Allow emulation if .get_temp is still not available */
> + if (tz->ops->get_temp) {
> + ret = tz->ops->get_temp(tz, temp);
> + if (!ret)
> + real_temp = *temp;
> + }
>
> if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz-
> >emul_temperature) {
> + enum thermal_trip_type type;
> + int count;
> +
> + ret = 0;
> for (count = 0; count < tz->trips; count++) {
> ret = tz->ops->get_trip_type(tz, count,
> &type);
> if (!ret && type == THERMAL_TRIP_CRITICAL) {
> @@ -498,17 +505,17 @@ int thermal_zone_get_temp(struct
> thermal_zone_device *tz, int *temp)
> * is below the critical temperature so that the
> emulation code
> * cannot hide critical conditions.
> */
> - if (!ret && *temp < crit_temp)
> + if (!ret && real_temp < crit_temp)
> *temp = tz->emul_temperature;
> }
>
> mutex_unlock(&tz->lock);
> -exit:
> +
> return ret;
> }
> EXPORT_SYMBOL_GPL(thermal_zone_get_temp);
>
> -static void update_temperature(struct thermal_zone_device *tz)
> +static int update_temperature(struct thermal_zone_device *tz)
> {
> int temp, ret;
>
> @@ -518,7 +525,7 @@ static void update_temperature(struct
> thermal_zone_device *tz)
> dev_warn(&tz->device,
> "failed to read out thermal zone
> (%d)\n",
> ret);
> - return;
> + return ret;
> }
>
> mutex_lock(&tz->lock);
> @@ -529,17 +536,17 @@ static void update_temperature(struct
> thermal_zone_device *tz)
> trace_thermal_temperature(tz);
> dev_dbg(&tz->device, "last_temperature=%d,
> current_temperature=%d\n",
> tz->last_temperature, tz-
> >temperature);
> +
> + return 0;
> }
>
> void thermal_zone_device_update(struct thermal_zone_device *tz)
> {
> int count;
>
> - if (!tz->ops->get_temp)
> + if (update_temperature(tz))
> return;
>
> - update_temperature(tz);
> -
> for (count = 0; count < tz->trips; count++)
> handle_thermal_trip(tz, count);
>
next prev parent reply other threads:[~2016-03-16 0:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-17 19:13 [PATCHv2 0/3] thermal: rework core to improve userspace interaction Eduardo Valentin
2015-12-17 19:13 ` [PATCHv2 1/3] thermal: setup monitor only once after handling trips Eduardo Valentin
2015-12-17 19:13 ` [PATCHv2 2/3] thermal: rework core to allow emul_temp to be treated as regular temp Eduardo Valentin
2016-03-16 0:09 ` Pandruvada, Srinivas [this message]
2015-12-17 19:13 ` [PATCHv2 3/3] thermal: improve hot trip handling Eduardo Valentin
2016-01-05 9:46 ` Geert Uytterhoeven
2016-02-03 23:24 ` Srikar Srimath Tirumala
2016-03-16 0:14 ` Pandruvada, Srinivas
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=1458083216.4486.42.camel@intel.com \
--to=srinivas.pandruvada@intel.com \
--cc=edubezval@gmail.com \
--cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).