On Sun, Sep 27, 2015 at 06:48:28AM +0100, Chen Yu wrote:
> From: Zhang Rui <[email protected]>
> 
> After thermal zone device registered, as we have not read any
> temperature before, thus tz->temperature should not be 0,
> which actually means 0C, and thermal trend is not available.
> In this case, we need specially handling for the first
> thermal_zone_device_update().
> 
> Both thermal core framework and step_wise governor is
> enhanced to handle this.

It may be worth pointing out that the step_wise governor is the only
one that uses trends, so it's the only thermal governor that needs to
be updated.

> CC: <[email protected]> #3.18+
> Tested-by: Manuel Krause <[email protected]>
> Tested-by: szegad <[email protected]>
> Tested-by: prash <[email protected]>
> Tested-by: amish <[email protected]>
> Tested-by: Matthias <[email protected]>
> Signed-off-by: Zhang Rui <[email protected]>
> Signed-off-by: Chen Yu <[email protected]>

One minor nit below, other than that,

Reviewed-by: Javi Merino <[email protected]>

> ---
>  drivers/thermal/step_wise.c    | 18 ++++++++++++++++--
>  drivers/thermal/thermal_core.c | 19 +++++++++++++++++--
>  drivers/thermal/thermal_core.h |  1 +
>  include/linux/thermal.h        |  3 +++
>  4 files changed, 37 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
> index 2f9f708..405de04 100644
> --- a/drivers/thermal/step_wise.c
> +++ b/drivers/thermal/step_wise.c
> @@ -63,6 +63,19 @@ static unsigned long get_target_state(struct 
> thermal_instance *instance,
>       next_target = instance->target;
>       dev_dbg(&cdev->device, "cur_state=%ld\n", cur_state);
>  
> +     if (!instance->initialized) {
> +             if (throttle) {
> +                     next_target = (cur_state + 1) >= instance->upper ?
> +                                     instance->upper :
> +                                     ((cur_state + 1) < instance->lower ?
> +                                     instance->lower : (cur_state + 1));
> +             } else {
> +                     next_target = THERMAL_NO_TARGET;
> +             }
> +
> +             return next_target;
> +     }
> +
>       switch (trend) {
>       case THERMAL_TREND_RAISING:
>               if (throttle) {
> @@ -149,7 +162,8 @@ static void thermal_zone_trip_update(struct 
> thermal_zone_device *tz, int trip)
>               dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
>                                       old_target, (int)instance->target);
>  
> -             if (old_target == instance->target)
> +             if (instance->initialized &&
> +                 old_target == instance->target)

nit: it fits in one line,

                if (instance->initialized && old_target == instance->target)

is 77 characters.

Cheers,
Javi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to