Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752813AbcKSDYM (ORCPT ); Fri, 18 Nov 2016 22:24:12 -0500 Received: from m50-138.163.com ([123.125.50.138]:33247 "EHLO m50-138.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752223AbcKSDYL (ORCPT ); Fri, 18 Nov 2016 22:24:11 -0500 Subject: Re: [PATCH 1/3] thermal: handle get_temp() errors properly To: Brian Norris References: <1479513177-81504-1-git-send-email-briannorris@chromium.org> Cc: Zhang Rui , Eduardo Valentin , Heiko Stuebner , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Barber , linux-rockchip@lists.infradead.org, Caesar Wang From: Caesar Wang Message-ID: Date: Sat, 19 Nov 2016 11:21:39 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1479513177-81504-1-git-send-email-briannorris@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: C9GowADXIQtDxS9YBrxrFA--.57665S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7ArW5AF4rXFWUurWxXw1xuFg_yoW8Xry3pF 4UGFWqyrWkGr4Ut3W2k3ykZr4qyayvqFyUur1kGw15Wws8Jrya9Fy5GF1YyrWrGa4UXFWa 9r1DZFyYy3WDZrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jdBMtUUUUU= X-Originating-IP: [103.29.142.67] X-CM-SenderInfo: 5vdv3yhhz03qqrwthudrp/xtbB0xEmlVXlWm3PygACsx Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1476 Lines: 43 Brian, 在 2016年11月19日 07:52, Brian Norris 写道: > If using CONFIG_THERMAL_EMULATION, there's a corner case where we might > get an error from the zone's get_temp() callback, but we'll ignore that > and keep using its value. Let's just error out properly instead. > > Signed-off-by: Brian Norris Tested-by: Caesar Wang [ 8.111296] thermal thermal_zone4: power_allocator: sustainable_power will be estimated [ 8.119420] thermal_zone_get_temp:537 the ret=-19, no such device, look like the A/D value had no ready yet. .. Anyway, this patch is useful for improving thermal. -Caesar > --- > drivers/thermal/thermal_core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index 911fd964c742..0fa497f10d25 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -494,6 +494,8 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) > mutex_lock(&tz->lock); > > ret = tz->ops->get_temp(tz, temp); > + if (ret) > + goto exit_unlock; > > if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { > for (count = 0; count < tz->trips; count++) { > @@ -514,6 +516,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) > *temp = tz->emul_temperature; > } > > +exit_unlock: > mutex_unlock(&tz->lock); > exit: > return ret;