2013-05-29 21:37:31

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCH 1/1] thermal: consider emul_temperature while computing trend

In case emulated temperature is in use, using the trend
provided by driver layer can lead to bogus situation.
In this case, debugger user would set a temperature value,
but the trend would be from driver computation.

To avoid this situation, this patch changes the get_tz_trend()
to consider the emulated temperature whenever that is in use.

Cc: Zhang Rui <[email protected]>
Cc: Amit Daniel Kachhap <[email protected]>
Cc: Durgadoss R <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Eduardo Valentin <[email protected]>
---
drivers/thermal/thermal_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index d755440..c00dc92 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -155,7 +155,8 @@ int get_tz_trend(struct thermal_zone_device *tz, int trip)
{
enum thermal_trend trend;

- if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend)) {
+ if (tz->emul_temperature || !tz->ops->get_trend ||
+ tz->ops->get_trend(tz, trip, &trend)) {
if (tz->temperature > tz->last_temperature)
trend = THERMAL_TREND_RAISING;
else if (tz->temperature < tz->last_temperature)
--
1.8.2.1.342.gfa7285d


2013-06-13 02:31:47

by Zhang, Rui

[permalink] [raw]
Subject: Re: [PATCH 1/1] thermal: consider emul_temperature while computing trend

On Wed, 2013-05-29 at 17:37 -0400, Eduardo Valentin wrote:
> In case emulated temperature is in use, using the trend
> provided by driver layer can lead to bogus situation.
> In this case, debugger user would set a temperature value,
> but the trend would be from driver computation.
>
> To avoid this situation, this patch changes the get_tz_trend()
> to consider the emulated temperature whenever that is in use.
>
> Cc: Zhang Rui <[email protected]>
> Cc: Amit Daniel Kachhap <[email protected]>
> Cc: Durgadoss R <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Eduardo Valentin <[email protected]>

patch applied.

thanks,
rui
> ---
> drivers/thermal/thermal_core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index d755440..c00dc92 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -155,7 +155,8 @@ int get_tz_trend(struct thermal_zone_device *tz, int trip)
> {
> enum thermal_trend trend;
>
> - if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend)) {
> + if (tz->emul_temperature || !tz->ops->get_trend ||
> + tz->ops->get_trend(tz, trip, &trend)) {
> if (tz->temperature > tz->last_temperature)
> trend = THERMAL_TREND_RAISING;
> else if (tz->temperature < tz->last_temperature)

2013-06-13 04:54:14

by R, Durgadoss

[permalink] [raw]
Subject: RE: [PATCH 1/1] thermal: consider emul_temperature while computing trend

> -----Original Message-----
> From: [email protected] [mailto:linux-pm-
> [email protected]] On Behalf Of Eduardo Valentin
> Sent: Thursday, May 30, 2013 3:07 AM
> To: Zhang, Rui
> Cc: Eduardo Valentin; Amit Daniel Kachhap; R, Durgadoss; linux-
> [email protected]; [email protected]
> Subject: [PATCH 1/1] thermal: consider emul_temperature while computing
> trend
>
> In case emulated temperature is in use, using the trend
> provided by driver layer can lead to bogus situation.
> In this case, debugger user would set a temperature value,
> but the trend would be from driver computation.
>
> To avoid this situation, this patch changes the get_tz_trend()
> to consider the emulated temperature whenever that is in use.

Nice catch.
Sorry, I missed looking at it earlier. Just got woken up by Rui's reply
on this. The patch looks fine to me.

Thanks,
Durga
>
> Cc: Zhang Rui <[email protected]>
> Cc: Amit Daniel Kachhap <[email protected]>
> Cc: Durgadoss R <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Eduardo Valentin <[email protected]>
> ---
> drivers/thermal/thermal_core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/thermal_core.c
> b/drivers/thermal/thermal_core.c
> index d755440..c00dc92 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -155,7 +155,8 @@ int get_tz_trend(struct thermal_zone_device *tz, int
> trip)
> {
> enum thermal_trend trend;
>
> - if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend)) {
> + if (tz->emul_temperature || !tz->ops->get_trend ||
> + tz->ops->get_trend(tz, trip, &trend)) {
> if (tz->temperature > tz->last_temperature)
> trend = THERMAL_TREND_RAISING;
> else if (tz->temperature < tz->last_temperature)
> --
> 1.8.2.1.342.gfa7285d
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html