From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757506AbbI1O2U (ORCPT ); Mon, 28 Sep 2015 10:28:20 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.140]:56431 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756584AbbI1O2S (ORCPT ); Mon, 28 Sep 2015 10:28:18 -0400 Date: Mon, 28 Sep 2015 15:28:13 +0100 From: Javi Merino To: Chen Yu Cc: "linux-pm@vger.kernel.org" , "edubezval@gmail.com" , "rui.zhang@intel.com" , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: Re: [PATCH 1/3] Thermal: initialize thermal zone device correctly Message-ID: <20150928142812.GA8359@e104805> References: <1443332908-13948-1-git-send-email-yu.c.chen@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1443332908-13948-1-git-send-email-yu.c.chen@intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 27, 2015 at 06:48:28AM +0100, Chen Yu wrote: > From: Zhang Rui > > 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: #3.18+ > Tested-by: Manuel Krause > Tested-by: szegad > Tested-by: prash > Tested-by: amish > Tested-by: Matthias > Signed-off-by: Zhang Rui > Signed-off-by: Chen Yu One minor nit below, other than that, Reviewed-by: Javi Merino > --- > 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